1 import ./make-test-python.nix ({ lib, ... }: {
2 name = "user-activation-scripts";
3 meta = with lib.maintainers; { maintainers = [ chkno ]; };
6 system.switch.enable = true;
7 system.userActivationScripts.foo = "mktemp ~/user-activation-ran.XXXXXX";
9 initialPassword = "pass1";
12 systemd.user.tmpfiles.users.alice.rules = [ "r %h/file-to-remove" ];
16 def verify_user_activation_run_count(n):
18 '[[ "$(find /home/alice/ -name user-activation-ran.\\* | wc -l)" == %s ]]' % n
22 machine.wait_for_unit("multi-user.target")
23 machine.wait_for_unit("getty@tty1.service")
24 machine.wait_until_tty_matches("1", "login: ")
25 machine.send_chars("alice\n")
26 machine.wait_until_tty_matches("1", "Password: ")
27 machine.send_chars("pass1\n")
28 machine.send_chars("touch login-ok\n")
29 machine.wait_for_file("/home/alice/login-ok")
30 verify_user_activation_run_count(1)
32 machine.succeed("touch /home/alice/file-to-remove")
33 machine.succeed("/run/current-system/bin/switch-to-configuration test")
34 verify_user_activation_run_count(2)
35 machine.succeed("[[ ! -f /home/alice/file-to-remove ]] || false")