summaryrefslogtreecommitdiffstats
path: root/tests/nixos/special-args.nix
blob: 322300a46da851a39952225f38f7891cd78bb324 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
{
  hjemModule,
  hjemTest,
  hello,
}: let
  userHome = "/home/alice";
in
  hjemTest {
    name = "hjem-basic";
    nodes = {
      node1 = {
        imports = [hjemModule];

        users.groups.alice = {};
        users.users.alice = {
          isNormalUser = true;
          home = userHome;
          password = "";
        };

        hjem = {
          linker = null;
          # Things like username, home directory or credentials should not really
          # be put into specialArgs, but users do it anyway. Lets test for a very
          # basic case of 'username' being passed to specialArgs as a string and
          # is consumed in a file later on.
          specialArgs = {username = "alice";};
          users.alice = {username, ...}: {
            enable = true;
            packages = [hello];
            files.".config/fooconfig" = {
              text = "My username is ${username}";
            };
          };
        };
      };
    };

    testScript = ''
      machine.succeed("loginctl enable-linger alice")
      machine.wait_until_succeeds("systemctl --user --machine=alice@ is-active systemd-tmpfiles-setup.service")

      # Test if the config file is properly generated, and contains the desired string1
      machine.succeed("grep alice ~alice/.config/fooconfig")
    '';
  }