Files
nixpkgs/nixos/tests/systemd-misc.nix
nikstur d36077c0b6 nixos/systemd: fix modprobe
Upstream systemd changed how modprobe is discovered. It is now searched
for on path. Thus, add the kmod package to the ExecSearchPath of the
modprobe@.service.
2026-04-07 00:30:27 +02:00

70 lines
1.6 KiB
Nix

{ pkgs, ... }:
let
exampleScript = pkgs.writeTextFile {
name = "example.sh";
text = ''
#! ${pkgs.runtimeShell} -e
while true; do
echo "Example script running" >&2
${pkgs.coreutils}/bin/sleep 1
done
'';
executable = true;
};
unitFile = pkgs.writeTextFile {
name = "example.service";
text = ''
[Unit]
Description=Example systemd service unit file
[Service]
ExecStart=${exampleScript}
[Install]
WantedBy=multi-user.target
'';
};
in
{
name = "systemd-misc";
nodes.machine =
{ pkgs, lib, ... }:
{
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 = ''
machine.wait_for_unit("multi-user.target")
machine.succeed("mkdir -p /etc/systemd-rw/system")
machine.succeed(
"cp ${unitFile} /etc/systemd-rw/system/example.service"
)
machine.succeed("systemctl start example.service")
machine.succeed("systemctl status example.service | grep 'Active: active'")
machine.succeed("systemctl show --property TasksMax --value user-1000.slice | grep 100")
with subtest("modprobe@ services work"):
modprobe_service_status = machine.succeed("systemctl show --property ExecMainStatus modprobe@configfs.service")
print(modprobe_service_status)
t.assertEqual("ExecMainStatus=0\n", modprobe_service_status)
'';
}