nixos/systemd: Allow creation of unit directories
This patch allows creation of files like /etc/systemd/system/user-.slice.d/limits.conf with systemd.units."user-.slice.d/limits.conf" = { text = '' [Slice] CPUAccounting=yes CPUQuota=50% ''; }; which previously threw an error Also renames the systemd-unit-path test to sytsemd-misc, and extends it to test that `systemd.units` can handle directories. In this case we make sure that resource limits specified in user slices apply.
This commit is contained in:
parent
4d60081494
commit
c70a466d21
|
@ -23,8 +23,9 @@ in rec {
|
||||||
inherit (unit) text;
|
inherit (unit) text;
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
mkdir -p $out
|
name=${shellEscape name}
|
||||||
echo -n "$text" > $out/${shellEscape name}
|
mkdir -p "$out/$(dirname "$name")"
|
||||||
|
echo -n "$text" > "$out/$name"
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
pkgs.runCommand "unit-${mkPathSafeName name}-disabled"
|
pkgs.runCommand "unit-${mkPathSafeName name}-disabled"
|
||||||
|
@ -32,8 +33,9 @@ in rec {
|
||||||
allowSubstitutes = false;
|
allowSubstitutes = false;
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
mkdir -p $out
|
name=${shellEscape name}
|
||||||
ln -s /dev/null $out/${shellEscape name}
|
mkdir -p "$out/$(dirname "$name")"
|
||||||
|
ln -s /dev/null "$out/$name"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
boolValues = [true false "yes" "no"];
|
boolValues = [true false "yes" "no"];
|
||||||
|
|
|
@ -518,7 +518,7 @@ in
|
||||||
systemd-networkd-vrf = handleTest ./systemd-networkd-vrf.nix {};
|
systemd-networkd-vrf = handleTest ./systemd-networkd-vrf.nix {};
|
||||||
systemd-nspawn = handleTest ./systemd-nspawn.nix {};
|
systemd-nspawn = handleTest ./systemd-nspawn.nix {};
|
||||||
systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
|
systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
|
||||||
systemd-unit-path = handleTest ./systemd-unit-path.nix {};
|
systemd-misc = handleTest ./systemd-misc.nix {};
|
||||||
taskserver = handleTest ./taskserver.nix {};
|
taskserver = handleTest ./taskserver.nix {};
|
||||||
teeworlds = handleTest ./teeworlds.nix {};
|
teeworlds = handleTest ./teeworlds.nix {};
|
||||||
telegraf = handleTest ./telegraf.nix {};
|
telegraf = handleTest ./telegraf.nix {};
|
||||||
|
|
|
@ -29,10 +29,23 @@ let
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = "systemd-unit-path";
|
name = "systemd-misc";
|
||||||
|
|
||||||
machine = { pkgs, lib, ... }: {
|
machine = { pkgs, lib, ... }: {
|
||||||
boot.extraSystemdUnitPaths = [ "/etc/systemd-rw/system" ];
|
boot.extraSystemdUnitPaths = [ "/etc/systemd-rw/system" ];
|
||||||
|
|
||||||
|
users.users.limited = {
|
||||||
|
isNormalUser = true;
|
||||||
|
uid = 1000;
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.units."user-1000.slice.d/limits.conf" = {
|
||||||
|
text = ''
|
||||||
|
[Slice]
|
||||||
|
TasksAccounting=yes
|
||||||
|
TasksMax=100
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
|
@ -43,5 +56,7 @@ in
|
||||||
)
|
)
|
||||||
machine.succeed("systemctl start example.service")
|
machine.succeed("systemctl start example.service")
|
||||||
machine.succeed("systemctl status example.service | grep 'Active: active'")
|
machine.succeed("systemctl status example.service | grep 'Active: active'")
|
||||||
|
|
||||||
|
machine.succeed("systemctl show --property TasksMax --value user-1000.slice | grep 100")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
Loading…
Reference in New Issue
Block a user