systemd: add slice support

This commit is contained in:
Markov Dmitry 2016-12-20 09:21:52 +03:00 committed by Jörg Thalheim
parent ccbce6b11a
commit efd5508b89
2 changed files with 32 additions and 0 deletions

View File

@ -465,4 +465,20 @@ in rec {
targetOptions = commonUnitOptions; 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.
'';
};
};
} }

View File

@ -375,6 +375,15 @@ let
''; '';
}; };
sliceToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
text = commonUnitText def +
''
[Slice]
${attrsToSection def.sliceConfig}
'';
};
in 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 { systemd.generators = mkOption {
type = types.attrsOf types.path; type = types.attrsOf types.path;
default = {}; default = {};
@ -748,6 +763,7 @@ in
// mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit n v)) cfg.sockets // 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}.timer" (timerToUnit n v)) cfg.timers
// mapAttrs' (n: v: nameValuePair "${n}.path" (pathToUnit n v)) cfg.paths // mapAttrs' (n: v: nameValuePair "${n}.path" (pathToUnit n v)) cfg.paths
// mapAttrs' (n: v: nameValuePair "${n}.slice" (sliceToUnit n v)) cfg.slices
// listToAttrs (map // listToAttrs (map
(v: let n = escapeSystemdPath v.where; (v: let n = escapeSystemdPath v.where;
in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts) in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts)