Skip to content

Commit efd5508

Browse files
Markov DmitryMic92
Markov Dmitry
authored andcommittedDec 20, 2016
systemd: add slice support
1 parent ccbce6b commit efd5508

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
 

Diff for: ‎nixos/modules/system/boot/systemd-unit-options.nix

+16
Original file line numberDiff line numberDiff line change
@@ -465,4 +465,20 @@ in rec {
465465

466466
targetOptions = commonUnitOptions;
467467

468+
sliceOptions = commonUnitOptions // {
469+
470+
sliceConfig = mkOption {
471+
default = {};
472+
example = { MemoryMax = "2G"; };
473+
type = types.attrsOf unitOption;
474+
description = ''
475+
Each attribute in this set specifies an option in the
476+
<literal>[Slice]</literal> section of the unit. See
477+
<citerefentry><refentrytitle>systemd.slice</refentrytitle>
478+
<manvolnum>5</manvolnum></citerefentry> for details.
479+
'';
480+
};
481+
482+
};
483+
468484
}

Diff for: ‎nixos/modules/system/boot/systemd.nix

+16
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,15 @@ let
375375
'';
376376
};
377377

378+
sliceToUnit = name: def:
379+
{ inherit (def) wantedBy requiredBy enable;
380+
text = commonUnitText def +
381+
''
382+
[Slice]
383+
${attrsToSection def.sliceConfig}
384+
'';
385+
};
386+
378387
in
379388

380389
{
@@ -458,6 +467,12 @@ in
458467
'';
459468
};
460469

470+
systemd.slices = mkOption {
471+
default = {};
472+
type = with types; attrsOf (submodule [ { options = sliceOptions; } unitConfig] );
473+
description = "Definition of slice configurations.";
474+
};
475+
461476
systemd.generators = mkOption {
462477
type = types.attrsOf types.path;
463478
default = {};
@@ -748,6 +763,7 @@ in
748763
// mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit n v)) cfg.sockets
749764
// mapAttrs' (n: v: nameValuePair "${n}.timer" (timerToUnit n v)) cfg.timers
750765
// mapAttrs' (n: v: nameValuePair "${n}.path" (pathToUnit n v)) cfg.paths
766+
// mapAttrs' (n: v: nameValuePair "${n}.slice" (sliceToUnit n v)) cfg.slices
751767
// listToAttrs (map
752768
(v: let n = escapeSystemdPath v.where;
753769
in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts)

0 commit comments

Comments
 (0)
Please sign in to comment.