blob: 4231845303d4d288a292f30c12760d51499e7f0f (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
{
hjemModule,
hjemTest,
hello,
lib,
formats,
}: 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.users = {
alice = {
enable = true;
packages = [hello];
files = {
".config/foo" = {
text = "Hello world!";
};
".config/bar.json" = {
generator = lib.generators.toJSON {};
value = {bar = true;};
};
".config/baz.toml" = {
generator = (formats.toml {}).generate "baz.toml";
value = {baz = true;};
};
};
};
};
# Also test systemd-tmpfiles internally
systemd.user.tmpfiles = {
rules = [
"d %h/user_tmpfiles_created"
];
users.alice.rules = [
"d %h/only_alice"
];
};
specialisation.unrelated.configuration.environment.etc."hjem-gc-test".text = "unrelated generation change";
};
};
testScript = {nodes, ...}: let
baseSystem = nodes.node1.system.build.toplevel;
unrelatedSystem = "${baseSystem}/specialisation/unrelated";
in ''
machine.succeed("loginctl enable-linger alice")
machine.wait_until_succeeds("systemctl --user --machine=alice@ is-active systemd-tmpfiles-setup.service")
# Test file created by Hjem
machine.succeed("[ -L ~alice/.config/foo ]")
machine.succeed("[ -L ~alice/.config/bar.json ]")
machine.succeed("[ -L ~alice/.config/baz.toml ]")
with subtest("Later generations retain unchanged linked sources across GC"):
machine.succeed("${unrelatedSystem}/bin/switch-to-configuration test")
machine.succeed("nix-store --query --requisites ${unrelatedSystem} | grep -Fx \"$(readlink ~alice/.config/foo)\"")
machine.succeed("nix-collect-garbage")
machine.succeed("test -e ~alice/.config/foo")
machine.succeed("grep -qx 'Hello world!' ~alice/.config/foo")
# Test regular files, created by systemd-tmpfiles
machine.succeed("[ -d ~alice/user_tmpfiles_created ]")
machine.succeed("[ -d ~alice/only_alice ]")
# Test user packages functioning
machine.succeed("su alice --login --command hello")
'';
}
|