diff --git a/modules/system/boot/shutdown.nix b/modules/system/boot/shutdown.nix index 23ddf6d02024..ad71a2e816e3 100644 --- a/modules/system/boot/shutdown.nix +++ b/modules/system/boot/shutdown.nix @@ -22,4 +22,6 @@ with pkgs.lib; ''; }; + boot.kernel.sysctl."kernel.poweroff_cmd" = "${config.systemd.package}/sbin/poweroff"; + } diff --git a/tests/misc.nix b/tests/misc.nix index 9f85877e8bbd..118ed8f45cba 100644 --- a/tests/misc.nix +++ b/tests/misc.nix @@ -33,6 +33,11 @@ $machine->waitForUnit("root-swapfile.swap"); $machine->succeed("ls -l /root/swapfile | grep 134217728"); }; + + # Test whether kernel.poweroff_cmd is set. + subtest "poweroff_cmd", sub { + $machine->succeed("[ -x \"\$(cat /proc/sys/kernel/poweroff_cmd)\" ]") + }; ''; }