about summary refs log tree commit diff
path: root/nixos/tests/systemd-user-tmpfiles-rules.nix
blob: bf29b4b57be3e0823aa87af223db4f352b6c329f (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
27
28
29
30
31
32
33
34
35
import ./make-test-python.nix ({ lib, ... }: {
  name = "systemd-user-tmpfiles-rules";

  meta = with lib.maintainers; {
    maintainers = [ schnusch ];
  };

  nodes.machine = { ... }: {
    users.users = {
      alice.isNormalUser = true;
      bob.isNormalUser = true;
    };

    systemd.user.tmpfiles = {
      rules = [
        "d %h/user_tmpfiles_created"
      ];
      users.alice.rules = [
        "d %h/only_alice"
      ];
    };
  };

  testScript = { ... }: ''
    machine.succeed("loginctl enable-linger alice bob")

    machine.wait_until_succeeds("systemctl --user --machine=alice@ is-active systemd-tmpfiles-setup.service")
    machine.succeed("[ -d ~alice/user_tmpfiles_created ]")
    machine.succeed("[ -d ~alice/only_alice ]")

    machine.wait_until_succeeds("systemctl --user --machine=bob@ is-active systemd-tmpfiles-setup.service")
    machine.succeed("[ -d ~bob/user_tmpfiles_created ]")
    machine.succeed("[ ! -e ~bob/only_alice ]")
  '';
})