about summary refs log tree commit diff
path: root/nixos/tests/systemd-shutdown.nix
blob: 688cd6dd2c1753fe3bcf6e05e0e752e56f8c31d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import ./make-test-python.nix ({ pkgs, systemdStage1 ? false, ...} : let
  msg = "Shutting down NixOS";
in {
  name = "systemd-shutdown";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ das_j ];
  };

  nodes.machine = {
    imports = [ ../modules/profiles/minimal.nix ];
    systemd.shutdownRamfs.contents."/etc/systemd/system-shutdown/shutdown-message".source = pkgs.writeShellScript "shutdown-message" ''
      echo "${msg}"
    '';
  };

  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
    machine.wait_for_console_text("Unmounting '/oldroot'")
    machine.wait_for_console_text("${msg}")
    # Don't try to sync filesystems
    machine.booted = False
  '';
})