nixos: systemd: Split unit types into separate module
This commit is contained in:
parent
397b8257a0
commit
52c98fc3e9
29
nixos/lib/systemd-types.nix
Normal file
29
nixos/lib/systemd-types.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{ lib, systemdUtils }:
|
||||||
|
|
||||||
|
with systemdUtils.lib;
|
||||||
|
with systemdUtils.unitOptions;
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
rec {
|
||||||
|
units = with types;
|
||||||
|
attrsOf (submodule ({ name, config, ... }: {
|
||||||
|
options = concreteUnitOptions;
|
||||||
|
config = { unit = mkDefault (systemdUtils.lib.makeUnit name config); };
|
||||||
|
}));
|
||||||
|
|
||||||
|
services = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig serviceConfig ]);
|
||||||
|
|
||||||
|
targets = with types; attrsOf (submodule [ { options = targetOptions; } unitConfig ]);
|
||||||
|
|
||||||
|
sockets = with types; attrsOf (submodule [ { options = socketOptions; } unitConfig ]);
|
||||||
|
|
||||||
|
timers = with types; attrsOf (submodule [ { options = timerOptions; } unitConfig ]);
|
||||||
|
|
||||||
|
paths = with types; attrsOf (submodule [ { options = pathOptions; } unitConfig ]);
|
||||||
|
|
||||||
|
slices = with types; attrsOf (submodule [ { options = sliceOptions; } unitConfig ]);
|
||||||
|
|
||||||
|
mounts = with types; listOf (submodule [ { options = mountOptions; } unitConfig mountConfig ]);
|
||||||
|
|
||||||
|
automounts = with types; listOf (submodule [ { options = automountOptions; } unitConfig automountConfig ]);
|
||||||
|
}
|
|
@ -197,5 +197,6 @@ rec {
|
||||||
systemdUtils = {
|
systemdUtils = {
|
||||||
lib = import ./systemd-lib.nix { inherit lib config pkgs; };
|
lib = import ./systemd-lib.nix { inherit lib config pkgs; };
|
||||||
unitOptions = import ./systemd-unit-options.nix { inherit lib systemdUtils; };
|
unitOptions = import ./systemd-unit-options.nix { inherit lib systemdUtils; };
|
||||||
|
types = import ./systemd-types.nix { inherit lib systemdUtils; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,6 @@ let
|
||||||
makeUnit
|
makeUnit
|
||||||
generateUnits
|
generateUnits
|
||||||
makeJobScript
|
makeJobScript
|
||||||
unitConfig
|
|
||||||
serviceConfig
|
|
||||||
mountConfig
|
|
||||||
automountConfig
|
|
||||||
commonUnitText
|
commonUnitText
|
||||||
targetToUnit
|
targetToUnit
|
||||||
serviceToUnit
|
serviceToUnit
|
||||||
|
@ -185,13 +181,7 @@ in
|
||||||
systemd.units = mkOption {
|
systemd.units = mkOption {
|
||||||
description = "Definition of systemd units.";
|
description = "Definition of systemd units.";
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule (
|
type = systemdUtils.types.units;
|
||||||
{ name, config, ... }:
|
|
||||||
{ options = concreteUnitOptions;
|
|
||||||
config = {
|
|
||||||
unit = mkDefault (makeUnit name config);
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.packages = mkOption {
|
systemd.packages = mkOption {
|
||||||
|
@ -203,37 +193,37 @@ in
|
||||||
|
|
||||||
systemd.targets = mkOption {
|
systemd.targets = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = targetOptions; } unitConfig] );
|
type = systemdUtils.types.targets;
|
||||||
description = "Definition of systemd target units.";
|
description = "Definition of systemd target units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services = mkOption {
|
systemd.services = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig serviceConfig ]);
|
type = systemdUtils.types.services;
|
||||||
description = "Definition of systemd service units.";
|
description = "Definition of systemd service units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.sockets = mkOption {
|
systemd.sockets = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = socketOptions; } unitConfig ]);
|
type = systemdUtils.types.sockets;
|
||||||
description = "Definition of systemd socket units.";
|
description = "Definition of systemd socket units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.timers = mkOption {
|
systemd.timers = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = timerOptions; } unitConfig ]);
|
type = systemdUtils.types.timers;
|
||||||
description = "Definition of systemd timer units.";
|
description = "Definition of systemd timer units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.paths = mkOption {
|
systemd.paths = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = pathOptions; } unitConfig ]);
|
type = systemdUtils.types.paths;
|
||||||
description = "Definition of systemd path units.";
|
description = "Definition of systemd path units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.mounts = mkOption {
|
systemd.mounts = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = with types; listOf (submodule [ { options = mountOptions; } unitConfig mountConfig ]);
|
type = systemdUtils.types.mounts;
|
||||||
description = ''
|
description = ''
|
||||||
Definition of systemd mount units.
|
Definition of systemd mount units.
|
||||||
This is a list instead of an attrSet, because systemd mandates the names to be derived from
|
This is a list instead of an attrSet, because systemd mandates the names to be derived from
|
||||||
|
@ -243,7 +233,7 @@ in
|
||||||
|
|
||||||
systemd.automounts = mkOption {
|
systemd.automounts = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = with types; listOf (submodule [ { options = automountOptions; } unitConfig automountConfig ]);
|
type = systemdUtils.types.automounts;
|
||||||
description = ''
|
description = ''
|
||||||
Definition of systemd automount units.
|
Definition of systemd automount units.
|
||||||
This is a list instead of an attrSet, because systemd mandates the names to be derived from
|
This is a list instead of an attrSet, because systemd mandates the names to be derived from
|
||||||
|
@ -253,7 +243,7 @@ in
|
||||||
|
|
||||||
systemd.slices = mkOption {
|
systemd.slices = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = sliceOptions; } unitConfig] );
|
type = systemdUtils.types.slices;
|
||||||
description = "Definition of slice configurations.";
|
description = "Definition of slice configurations.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,6 @@ let
|
||||||
(systemdUtils.lib)
|
(systemdUtils.lib)
|
||||||
makeUnit
|
makeUnit
|
||||||
generateUnits
|
generateUnits
|
||||||
makeJobScript
|
|
||||||
unitConfig
|
|
||||||
serviceConfig
|
|
||||||
commonUnitText
|
|
||||||
targetToUnit
|
targetToUnit
|
||||||
serviceToUnit
|
serviceToUnit
|
||||||
socketToUnit
|
socketToUnit
|
||||||
|
@ -57,48 +53,42 @@ in {
|
||||||
systemd.user.units = mkOption {
|
systemd.user.units = mkOption {
|
||||||
description = "Definition of systemd per-user units.";
|
description = "Definition of systemd per-user units.";
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule (
|
type = systemdUtils.types.units;
|
||||||
{ name, config, ... }:
|
|
||||||
{ options = concreteUnitOptions;
|
|
||||||
config = {
|
|
||||||
unit = mkDefault (makeUnit name config);
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.paths = mkOption {
|
systemd.user.paths = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = pathOptions; } unitConfig ]);
|
type = systemdUtils.types.paths;
|
||||||
description = "Definition of systemd per-user path units.";
|
description = "Definition of systemd per-user path units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.services = mkOption {
|
systemd.user.services = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig serviceConfig ] );
|
type = systemdUtils.types.services;
|
||||||
description = "Definition of systemd per-user service units.";
|
description = "Definition of systemd per-user service units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.slices = mkOption {
|
systemd.user.slices = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = sliceOptions; } unitConfig ] );
|
type = systemdUtils.types.slices;
|
||||||
description = "Definition of systemd per-user slice units.";
|
description = "Definition of systemd per-user slice units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.sockets = mkOption {
|
systemd.user.sockets = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = socketOptions; } unitConfig ] );
|
type = systemdUtils.types.sockets;
|
||||||
description = "Definition of systemd per-user socket units.";
|
description = "Definition of systemd per-user socket units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.targets = mkOption {
|
systemd.user.targets = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = targetOptions; } unitConfig] );
|
type = systemdUtils.types.targets;
|
||||||
description = "Definition of systemd per-user target units.";
|
description = "Definition of systemd per-user target units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.timers = mkOption {
|
systemd.user.timers = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; attrsOf (submodule [ { options = timerOptions; } unitConfig ] );
|
type = systemdUtils.types.timers;
|
||||||
description = "Definition of systemd per-user timer units.";
|
description = "Definition of systemd per-user timer units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue