systemd: add slice support
This commit is contained in:
parent
ccbce6b11a
commit
efd5508b89
@ -465,4 +465,20 @@ in rec {
|
||||
|
||||
targetOptions = commonUnitOptions;
|
||||
|
||||
sliceOptions = commonUnitOptions // {
|
||||
|
||||
sliceConfig = mkOption {
|
||||
default = {};
|
||||
example = { MemoryMax = "2G"; };
|
||||
type = types.attrsOf unitOption;
|
||||
description = ''
|
||||
Each attribute in this set specifies an option in the
|
||||
<literal>[Slice]</literal> section of the unit. See
|
||||
<citerefentry><refentrytitle>systemd.slice</refentrytitle>
|
||||
<manvolnum>5</manvolnum></citerefentry> for details.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -375,6 +375,15 @@ let
|
||||
'';
|
||||
};
|
||||
|
||||
sliceToUnit = name: def:
|
||||
{ inherit (def) wantedBy requiredBy enable;
|
||||
text = commonUnitText def +
|
||||
''
|
||||
[Slice]
|
||||
${attrsToSection def.sliceConfig}
|
||||
'';
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
@ -458,6 +467,12 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.slices = mkOption {
|
||||
default = {};
|
||||
type = with types; attrsOf (submodule [ { options = sliceOptions; } unitConfig] );
|
||||
description = "Definition of slice configurations.";
|
||||
};
|
||||
|
||||
systemd.generators = mkOption {
|
||||
type = types.attrsOf types.path;
|
||||
default = {};
|
||||
@ -748,6 +763,7 @@ in
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit n v)) cfg.sockets
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.timer" (timerToUnit n v)) cfg.timers
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.path" (pathToUnit n v)) cfg.paths
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.slice" (sliceToUnit n v)) cfg.slices
|
||||
// listToAttrs (map
|
||||
(v: let n = escapeSystemdPath v.where;
|
||||
in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts)
|
||||
|
Loading…
Reference in New Issue
Block a user