diff --git a/nixos/modules/system/boot/systemd/user.nix b/nixos/modules/system/boot/systemd/user.nix index 1b6398d2f929..64dc19633eca 100644 --- a/nixos/modules/system/boot/systemd/user.nix +++ b/nixos/modules/system/boot/systemd/user.nix @@ -230,5 +230,9 @@ in { }); }) cfg.tmpfiles.users; + + system.userActivationScripts.tmpfiles = '' + ${config.systemd.package}/bin/systemd-tmpfiles --user --create --remove + ''; }; } diff --git a/nixos/tests/user-activation-scripts.nix b/nixos/tests/user-activation-scripts.nix index 5df072ce0508..ebd96b019e92 100644 --- a/nixos/tests/user-activation-scripts.nix +++ b/nixos/tests/user-activation-scripts.nix @@ -8,6 +8,7 @@ import ./make-test-python.nix ({ lib, ... }: { initialPassword = "pass1"; isNormalUser = true; }; + systemd.user.tmpfiles.users.alice.rules = [ "r %h/file-to-remove" ]; }; testScript = '' @@ -27,7 +28,9 @@ import ./make-test-python.nix ({ lib, ... }: { 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") ''; })