2022-04-24 21:47:28 +03:00
|
|
|
import ./make-test-python.nix ({ pkgs, systemdStage1 ? false, ...} : let
|
|
|
|
msg = "Shutting down NixOS";
|
|
|
|
in {
|
2022-04-15 13:23:02 +03:00
|
|
|
name = "systemd-shutdown";
|
|
|
|
meta = with pkgs.lib.maintainers; {
|
|
|
|
maintainers = [ das_j ];
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes.machine = {
|
|
|
|
imports = [ ../modules/profiles/minimal.nix ];
|
2022-04-24 21:47:28 +03:00
|
|
|
systemd.shutdownRamfs.contents."/etc/systemd/system-shutdown/shutdown-message".source = pkgs.writeShellScript "shutdown-message" ''
|
|
|
|
echo "${msg}"
|
|
|
|
'';
|
2023-02-24 03:42:45 +03:00
|
|
|
boot.initrd.systemd.enable = systemdStage1;
|
2022-04-15 13:23:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
# .shutdown() would wait for the machine to power off
|
|
|
|
machine.succeed("systemctl poweroff")
|
|
|
|
# Message printed by systemd-shutdown
|
2022-04-24 21:47:28 +03:00
|
|
|
machine.wait_for_console_text("Unmounting '/oldroot'")
|
|
|
|
machine.wait_for_console_text("${msg}")
|
2022-04-15 13:23:02 +03:00
|
|
|
# Don't try to sync filesystems
|
2023-07-29 01:52:48 +03:00
|
|
|
machine.wait_for_shutdown()
|
2022-04-15 13:23:02 +03:00
|
|
|
'';
|
|
|
|
})
|