mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
e39c9f13bc
Just like with system-wide tmpfiles, call `systemd-tmpfiles --create --remove` for users during activation. This fixes an issue where new entries in a user's tmpfiles are not reflected after activation, only at boot when the user service systemd-tmpfiles-setup.service runs or only after running systemd-tmpfiles manually.
37 lines
1.2 KiB
Nix
37 lines
1.2 KiB
Nix
import ./make-test-python.nix ({ lib, ... }: {
|
|
name = "user-activation-scripts";
|
|
meta = with lib.maintainers; { maintainers = [ chkno ]; };
|
|
|
|
nodes.machine = {
|
|
system.userActivationScripts.foo = "mktemp ~/user-activation-ran.XXXXXX";
|
|
users.users.alice = {
|
|
initialPassword = "pass1";
|
|
isNormalUser = true;
|
|
};
|
|
systemd.user.tmpfiles.users.alice.rules = [ "r %h/file-to-remove" ];
|
|
};
|
|
|
|
testScript = ''
|
|
def verify_user_activation_run_count(n):
|
|
machine.succeed(
|
|
'[[ "$(find /home/alice/ -name user-activation-ran.\\* | wc -l)" == %s ]]' % n
|
|
)
|
|
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
machine.wait_for_unit("getty@tty1.service")
|
|
machine.wait_until_tty_matches("1", "login: ")
|
|
machine.send_chars("alice\n")
|
|
machine.wait_until_tty_matches("1", "Password: ")
|
|
machine.send_chars("pass1\n")
|
|
machine.send_chars("touch login-ok\n")
|
|
machine.wait_for_file("/home/alice/login-ok")
|
|
verify_user_activation_run_count(1)
|
|
|
|
machine.succeed("touch /home/alice/file-to-remove")
|
|
machine.succeed("/run/current-system/bin/switch-to-configuration test")
|
|
verify_user_activation_run_count(2)
|
|
machine.succeed("[[ ! -f /home/alice/file-to-remove ]] || false")
|
|
'';
|
|
})
|