mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 06:19:00 +00:00
chore: reformat codebase
This commit is contained in:
parent
7f3f83c757
commit
1957df91ea
@ -3,7 +3,7 @@
|
|||||||
, meson
|
, meson
|
||||||
, ninja
|
, ninja
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
, inputs ? []
|
, inputs ? [ ]
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
74
flake.nix
74
flake.nix
@ -79,6 +79,21 @@
|
|||||||
|
|
||||||
outputs = inputs@{ self, nixpkgs, ... }:
|
outputs = inputs@{ self, nixpkgs, ... }:
|
||||||
let
|
let
|
||||||
|
# A set of image-related utilities for the flake outputs.
|
||||||
|
inherit (import ./lib/extras/images.nix { inherit lib inputs; }) mkHost mkHome mkImage listImagesWithSystems;
|
||||||
|
|
||||||
|
# We're considering this as the variant since we'll export the custom
|
||||||
|
# library as `lib` in the output attribute.
|
||||||
|
lib = nixpkgs.lib.extend (import ./lib/extras/extend-lib.nix);
|
||||||
|
|
||||||
|
# Just add systems here and it should add systems to the outputs.
|
||||||
|
defaultSystem = "x86_64-linux";
|
||||||
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
];
|
||||||
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
||||||
|
|
||||||
# A set of images with their metadata that is usually built for usual
|
# A set of images with their metadata that is usually built for usual
|
||||||
# purposes. The format used here is whatever formats nixos-generators
|
# purposes. The format used here is whatever formats nixos-generators
|
||||||
# support.
|
# support.
|
||||||
@ -88,29 +103,13 @@
|
|||||||
# A set of users with their metadata to be deployed with home-manager.
|
# A set of users with their metadata to be deployed with home-manager.
|
||||||
users = import ./setups/home-manager.nix { inherit lib inputs; };
|
users = import ./setups/home-manager.nix { inherit lib inputs; };
|
||||||
|
|
||||||
# A set of image-related utilities for the flake outputs.
|
|
||||||
inherit (import ./lib/extras/images.nix { inherit lib inputs; }) mkHost mkHome mkImage listImagesWithSystems;
|
|
||||||
|
|
||||||
# The order here is important(?).
|
# The order here is important(?).
|
||||||
overlays = lib.attrValues self.overlays;
|
overlays = lib.attrValues self.overlays;
|
||||||
|
|
||||||
defaultSystem = "x86_64-linux";
|
|
||||||
|
|
||||||
# Just add systems here and it should add systems to the outputs.
|
|
||||||
systems = [
|
|
||||||
"x86_64-linux"
|
|
||||||
"aarch64-linux"
|
|
||||||
];
|
|
||||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
|
||||||
|
|
||||||
extraArgs = {
|
extraArgs = {
|
||||||
inherit (inputs) nix-colors;
|
inherit (inputs) nix-colors;
|
||||||
};
|
};
|
||||||
|
|
||||||
# We're considering this as the variant since we'll export the custom
|
|
||||||
# library as `lib` in the output attribute.
|
|
||||||
lib = nixpkgs.lib.extend (import ./lib/extras/extend-lib.nix);
|
|
||||||
|
|
||||||
# The shared configuration for the entire list of hosts for this cluster.
|
# The shared configuration for the entire list of hosts for this cluster.
|
||||||
# Take note to only set as minimal configuration as possible since we're
|
# Take note to only set as minimal configuration as possible since we're
|
||||||
# also using this with the stable version of nixpkgs.
|
# also using this with the stable version of nixpkgs.
|
||||||
@ -365,28 +364,29 @@
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
apps = forAllSystems (system: let
|
apps = forAllSystems (system:
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
let
|
||||||
in
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
{
|
in
|
||||||
run-workflow-with-vm =
|
{
|
||||||
let
|
run-workflow-with-vm =
|
||||||
inputsArgs = lib.mapAttrsToList
|
let
|
||||||
(name: source:
|
inputsArgs = lib.mapAttrsToList
|
||||||
let
|
(name: source:
|
||||||
name' = if (name == "self") then "config" else name;
|
let
|
||||||
in
|
name' = if (name == "self") then "config" else name;
|
||||||
"'${name'}=${source}'")
|
in
|
||||||
inputs;
|
"'${name'}=${source}'")
|
||||||
script = pkgs.callPackage ./apps/run-workflow-with-vm {
|
inputs;
|
||||||
inputs = inputsArgs;
|
script = pkgs.callPackage ./apps/run-workflow-with-vm {
|
||||||
|
inputs = inputsArgs;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
type = "app";
|
||||||
|
program = "${script}/bin/run-workflow-with-vm";
|
||||||
};
|
};
|
||||||
in
|
});
|
||||||
{
|
|
||||||
type = "app";
|
|
||||||
program = "${script}/bin/run-workflow-with-vm";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
# Exposes only my library with the custom functions to make it easier to
|
# Exposes only my library with the custom functions to make it easier to
|
||||||
# include in other flakes for whatever reason may be.
|
# include in other flakes for whatever reason may be.
|
||||||
|
@ -75,7 +75,7 @@ let
|
|||||||
`PartOf=$COMPONENTID.target`).
|
`PartOf=$COMPONENTID.target`).
|
||||||
:::
|
:::
|
||||||
'';
|
'';
|
||||||
default = {};
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
targetUnit = lib.mkOption {
|
targetUnit = lib.mkOption {
|
||||||
@ -101,7 +101,7 @@ let
|
|||||||
gnome-session targets. This is on the user to manually set them.
|
gnome-session targets. This is on the user to manually set them.
|
||||||
:::
|
:::
|
||||||
'';
|
'';
|
||||||
default = {};
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
timerUnit = lib.mkOption {
|
timerUnit = lib.mkOption {
|
||||||
@ -110,11 +110,11 @@ let
|
|||||||
inherit (utils.systemdUtils.unitOptions) timerOptions commonUnitOptions;
|
inherit (utils.systemdUtils.unitOptions) timerOptions commonUnitOptions;
|
||||||
inherit (utils.systemdUtils.lib) unitConfig;
|
inherit (utils.systemdUtils.lib) unitConfig;
|
||||||
in
|
in
|
||||||
with lib.types; nullOr (submodule [
|
with lib.types; nullOr (submodule [
|
||||||
commonUnitOptions
|
commonUnitOptions
|
||||||
timerOptions
|
timerOptions
|
||||||
unitConfig
|
unitConfig
|
||||||
]);
|
]);
|
||||||
description = ''
|
description = ''
|
||||||
An optional systemd timer configuration to be generated. This should
|
An optional systemd timer configuration to be generated. This should
|
||||||
be configured if the session is managed by systemd.
|
be configured if the session is managed by systemd.
|
||||||
@ -134,11 +134,11 @@ let
|
|||||||
inherit (utils.systemdUtils.unitOptions) socketOptions commonUnitOptions;
|
inherit (utils.systemdUtils.unitOptions) socketOptions commonUnitOptions;
|
||||||
inherit (utils.systemdUtils.lib) unitConfig;
|
inherit (utils.systemdUtils.lib) unitConfig;
|
||||||
in
|
in
|
||||||
with lib.types; nullOr (submodule [
|
with lib.types; nullOr (submodule [
|
||||||
commonUnitOptions
|
commonUnitOptions
|
||||||
socketOptions
|
socketOptions
|
||||||
unitConfig
|
unitConfig
|
||||||
]);
|
]);
|
||||||
description = ''
|
description = ''
|
||||||
An optional systemd socket configuration to be generated. This should
|
An optional systemd socket configuration to be generated. This should
|
||||||
be configured if the session is managed by systemd.
|
be configured if the session is managed by systemd.
|
||||||
@ -158,11 +158,11 @@ let
|
|||||||
inherit (utils.systemdUtils.unitOptions) pathOptions commonUnitOptions;
|
inherit (utils.systemdUtils.unitOptions) pathOptions commonUnitOptions;
|
||||||
inherit (utils.systemdUtils.lib) unitConfig;
|
inherit (utils.systemdUtils.lib) unitConfig;
|
||||||
in
|
in
|
||||||
with lib.types; nullOr (submodule [
|
with lib.types; nullOr (submodule [
|
||||||
commonUnitOptions
|
commonUnitOptions
|
||||||
pathOptions
|
pathOptions
|
||||||
unitConfig
|
unitConfig
|
||||||
]);
|
]);
|
||||||
description = ''
|
description = ''
|
||||||
An optional systemd path configuration to be generated. This should
|
An optional systemd path configuration to be generated. This should
|
||||||
be configured if the session is managed by systemd.
|
be configured if the session is managed by systemd.
|
||||||
@ -206,30 +206,31 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = let
|
config =
|
||||||
scriptName = "${session.name}-${name}-script";
|
let
|
||||||
script = "${config.scriptPackage}/bin/${scriptName}";
|
scriptName = "${session.name}-${name}-script";
|
||||||
in
|
script = "${config.scriptPackage}/bin/${scriptName}";
|
||||||
{
|
in
|
||||||
id = "${session.name}.${name}";
|
{
|
||||||
|
id = "${session.name}.${name}";
|
||||||
|
|
||||||
# Make with the default configurations for the built-in-managed
|
# Make with the default configurations for the built-in-managed
|
||||||
# components.
|
# components.
|
||||||
desktopConfig = {
|
desktopConfig = {
|
||||||
name = lib.mkForce config.id;
|
name = lib.mkForce config.id;
|
||||||
desktopName = lib.mkDefault "${session.fullName} - ${config.description}";
|
desktopName = lib.mkDefault "${session.fullName} - ${config.description}";
|
||||||
exec = lib.mkForce script;
|
exec = lib.mkForce script;
|
||||||
noDisplay = lib.mkForce true;
|
noDisplay = lib.mkForce true;
|
||||||
onlyShowIn = [ "X-${session.fullName}" ];
|
onlyShowIn = [ "X-${session.fullName}" ];
|
||||||
extraConfig = {
|
extraConfig = {
|
||||||
X-GNOME-AutoRestart = lib.mkDefault "false";
|
X-GNOME-AutoRestart = lib.mkDefault "false";
|
||||||
X-GNOME-Autostart-Notify = lib.mkDefault "true";
|
X-GNOME-Autostart-Notify = lib.mkDefault "true";
|
||||||
X-GNOME-Autostart-Phase = lib.mkDefault "Application";
|
X-GNOME-Autostart-Phase = lib.mkDefault "Application";
|
||||||
X-GNOME-HiddenUnderSystemd = lib.mkDefault "true";
|
X-GNOME-HiddenUnderSystemd = lib.mkDefault "true";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Setting some recommendation and requirements for systemd-managed
|
Setting some recommendation and requirements for systemd-managed
|
||||||
gnome-session components. Note there are the missing directives that
|
gnome-session components. Note there are the missing directives that
|
||||||
COULD include some sane defaults here.
|
COULD include some sane defaults here.
|
||||||
@ -260,39 +261,39 @@ let
|
|||||||
Take note that the default service configuration is leaning on the
|
Take note that the default service configuration is leaning on the
|
||||||
desktop component being a simple type of service like how most NixOS
|
desktop component being a simple type of service like how most NixOS
|
||||||
service modules are deployed.
|
service modules are deployed.
|
||||||
*/
|
*/
|
||||||
serviceUnit = {
|
serviceUnit = {
|
||||||
script = lib.mkAfter script;
|
script = lib.mkAfter script;
|
||||||
description = lib.mkDefault config.description;
|
description = lib.mkDefault config.description;
|
||||||
|
|
||||||
# The typical workflow for service units to have them set as part of
|
# The typical workflow for service units to have them set as part of
|
||||||
# the respective target unit.
|
# the respective target unit.
|
||||||
requisite = [ "${config.id}.target" ];
|
requisite = [ "${config.id}.target" ];
|
||||||
before = [ "${config.id}.target" ];
|
before = [ "${config.id}.target" ];
|
||||||
partOf = [ "${config.id}.target" ];
|
partOf = [ "${config.id}.target" ];
|
||||||
|
|
||||||
# Some sane service configuration for a desktop component.
|
# Some sane service configuration for a desktop component.
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Slice = lib.mkDefault "session.slice";
|
Slice = lib.mkDefault "session.slice";
|
||||||
Restart = lib.mkDefault "on-failure";
|
Restart = lib.mkDefault "on-failure";
|
||||||
TimeoutStopSec = lib.mkDefault 5;
|
TimeoutStopSec = lib.mkDefault 5;
|
||||||
|
};
|
||||||
|
|
||||||
|
startLimitBurst = lib.mkDefault 3;
|
||||||
|
startLimitIntervalSec = lib.mkDefault 15;
|
||||||
|
|
||||||
|
unitConfig = {
|
||||||
|
# Units managed by gnome-session are required to have CollectMode=
|
||||||
|
# set to this value.
|
||||||
|
CollectMode = lib.mkForce "inactive-or-failed";
|
||||||
|
|
||||||
|
# We leave those up to the target units to start the services.
|
||||||
|
RefuseManualStart = lib.mkDefault true;
|
||||||
|
RefuseManualStop = lib.mkDefault true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
startLimitBurst = lib.mkDefault 3;
|
/*
|
||||||
startLimitIntervalSec = lib.mkDefault 15;
|
|
||||||
|
|
||||||
unitConfig = {
|
|
||||||
# Units managed by gnome-session are required to have CollectMode=
|
|
||||||
# set to this value.
|
|
||||||
CollectMode = lib.mkForce "inactive-or-failed";
|
|
||||||
|
|
||||||
# We leave those up to the target units to start the services.
|
|
||||||
RefuseManualStart = lib.mkDefault true;
|
|
||||||
RefuseManualStop = lib.mkDefault true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Similarly, there are things that COULD make it here but didn't for a
|
Similarly, there are things that COULD make it here but didn't for a
|
||||||
variety of reasons.
|
variety of reasons.
|
||||||
|
|
||||||
@ -301,36 +302,36 @@ let
|
|||||||
if we make it clear in the documentation or if it proves to be a
|
if we make it clear in the documentation or if it proves to be a
|
||||||
painful experience to configure this by a first-timer. For now, this is
|
painful experience to configure this by a first-timer. For now, this is
|
||||||
on the user to know.
|
on the user to know.
|
||||||
*/
|
*/
|
||||||
targetUnit = {
|
targetUnit = {
|
||||||
wants = [ "${config.id}.service" ];
|
wants = [ "${config.id}.service" ];
|
||||||
description = lib.mkDefault config.description;
|
description = lib.mkDefault config.description;
|
||||||
documentation = [
|
documentation = [
|
||||||
"man:gnome-session(1)"
|
"man:gnome-session(1)"
|
||||||
"man:systemd.special(7)"
|
"man:systemd.special(7)"
|
||||||
];
|
];
|
||||||
unitConfig.CollectMode = lib.mkForce "inactive-or-failed";
|
unitConfig.CollectMode = lib.mkForce "inactive-or-failed";
|
||||||
|
};
|
||||||
|
|
||||||
|
scriptPackage = pkgs.writeShellApplication {
|
||||||
|
name = scriptName;
|
||||||
|
runtimeInputs = [ cfg.package pkgs.dbus ];
|
||||||
|
text = ''
|
||||||
|
DESKTOP_AUTOSTART_ID="''${DESKTOP_AUTOSTART_ID:-}"
|
||||||
|
echo "$DESKTOP_AUTOSTART_ID"
|
||||||
|
test -n "$DESKTOP_AUTOSTART_ID" && {
|
||||||
|
dbus-send --print-reply --session \
|
||||||
|
--dest=org.gnome.SessionManager "/org/gnome/SessionManager" \
|
||||||
|
org.gnome.SessionManager.RegisterClient \
|
||||||
|
"string:${name}" "string:$DESKTOP_AUTOSTART_ID"
|
||||||
|
}
|
||||||
|
|
||||||
|
${config.script}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
desktopPackage = pkgs.makeDesktopItem config.desktopConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
scriptPackage = pkgs.writeShellApplication {
|
|
||||||
name = scriptName;
|
|
||||||
runtimeInputs = [ cfg.package pkgs.dbus ];
|
|
||||||
text = ''
|
|
||||||
DESKTOP_AUTOSTART_ID="''${DESKTOP_AUTOSTART_ID:-}"
|
|
||||||
echo "$DESKTOP_AUTOSTART_ID"
|
|
||||||
test -n "$DESKTOP_AUTOSTART_ID" && {
|
|
||||||
dbus-send --print-reply --session \
|
|
||||||
--dest=org.gnome.SessionManager "/org/gnome/SessionManager" \
|
|
||||||
org.gnome.SessionManager.RegisterClient \
|
|
||||||
"string:${name}" "string:$DESKTOP_AUTOSTART_ID"
|
|
||||||
}
|
|
||||||
|
|
||||||
${config.script}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
desktopPackage = pkgs.makeDesktopItem config.desktopConfig;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sessionType = { name, config, options, ... }: {
|
sessionType = { name, config, options, ... }: {
|
||||||
@ -508,22 +509,24 @@ let
|
|||||||
inherit (utils.systemdUtils.lib)
|
inherit (utils.systemdUtils.lib)
|
||||||
pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit;
|
pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit;
|
||||||
componentsUnits =
|
componentsUnits =
|
||||||
lib.foldlAttrs (acc: name: component:
|
lib.foldlAttrs
|
||||||
acc // {
|
(acc: name: component:
|
||||||
"${component.id}.service" = serviceToUnit component.id component.serviceUnit;
|
acc // {
|
||||||
"${component.id}.target" = targetToUnit component.id component.targetUnit;
|
"${component.id}.service" = serviceToUnit component.id component.serviceUnit;
|
||||||
} // lib.optionalAttrs (component.socketUnit != null) {
|
"${component.id}.target" = targetToUnit component.id component.targetUnit;
|
||||||
"${component.id}.socket" = socketToUnit component.id component.socketUnit;
|
} // lib.optionalAttrs (component.socketUnit != null) {
|
||||||
} // lib.optionalAttrs (component.timerUnit != null) {
|
"${component.id}.socket" = socketToUnit component.id component.socketUnit;
|
||||||
"${component.id}.timer" = timerToUnit component.id component.timerUnit;
|
} // lib.optionalAttrs (component.timerUnit != null) {
|
||||||
} // lib.optionalAttrs (component.pathUnit != null) {
|
"${component.id}.timer" = timerToUnit component.id component.timerUnit;
|
||||||
"${component.id}.path" = pathToUnit component.id component.pathUnit;
|
} // lib.optionalAttrs (component.pathUnit != null) {
|
||||||
})
|
"${component.id}.path" = pathToUnit component.id component.pathUnit;
|
||||||
{} config.components;
|
})
|
||||||
|
{ }
|
||||||
|
config.components;
|
||||||
in
|
in
|
||||||
componentsUnits // {
|
componentsUnits // {
|
||||||
"gnome-session@${name}.target" = targetToUnit "gnome-session@${name}" config.targetUnit;
|
"gnome-session@${name}.target" = targetToUnit "gnome-session@${name}" config.targetUnit;
|
||||||
};
|
};
|
||||||
|
|
||||||
# By default. set the required components from the given desktop
|
# By default. set the required components from the given desktop
|
||||||
# components.
|
# components.
|
||||||
@ -585,19 +588,23 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
installDesktopSessions = builtins.map (display:
|
installDesktopSessions = builtins.map
|
||||||
displayScripts.${display}) config.display;
|
(display:
|
||||||
|
displayScripts.${display})
|
||||||
|
config.display;
|
||||||
|
|
||||||
installSystemdUserUnits = lib.mapAttrsToList (n: v:
|
installSystemdUserUnits = lib.mapAttrsToList
|
||||||
if (v ? overrideStrategy && v.overrideStrategy == "asDropin") then ''
|
(n: v:
|
||||||
(
|
if (v ? overrideStrategy && v.overrideStrategy == "asDropin") then ''
|
||||||
unit="${v.unit}/${n}"
|
(
|
||||||
unit_filename=$(basename "$unit")
|
unit="${v.unit}/${n}"
|
||||||
install -Dm0644 "$unit" "$out/share/systemd/user/''${unit_filename}.d/session.conf"
|
unit_filename=$(basename "$unit")
|
||||||
)
|
install -Dm0644 "$unit" "$out/share/systemd/user/''${unit_filename}.d/session.conf"
|
||||||
'' else ''
|
)
|
||||||
install -Dm0644 "${v.unit}/${n}" -t "$out/share/systemd/user"
|
'' else ''
|
||||||
'') config.systemdUserUnits;
|
install -Dm0644 "${v.unit}/${n}" -t "$out/share/systemd/user"
|
||||||
|
'')
|
||||||
|
config.systemdUserUnits;
|
||||||
|
|
||||||
installDesktops = lib.mapAttrsToList
|
installDesktops = lib.mapAttrsToList
|
||||||
(_: p: ''
|
(_: p: ''
|
||||||
|
Loading…
Reference in New Issue
Block a user