3 name = "activation-etc-overlay-immutable";
5 meta.maintainers = with lib.maintainers; [ nikstur ];
7 nodes.machine = { pkgs, ... }: {
8 system.etc.overlay.enable = true;
9 system.etc.overlay.mutable = false;
12 systemd.sysusers.enable = true;
13 users.mutableUsers = false;
14 boot.initrd.systemd.enable = true;
15 boot.kernelPackages = pkgs.linuxPackages_latest;
16 time.timeZone = "Utc";
19 "mountpoint/.keep".text = "keep";
20 "filemount".text = "keep";
23 specialisation.new-generation.configuration = {
24 environment.etc."newgen".text = "newgen";
29 with subtest("/etc is mounted as an overlay"):
30 machine.succeed("findmnt --kernel --type overlay /etc")
32 with subtest("direct symlinks point to the target without indirection"):
33 assert machine.succeed("readlink -n /etc/localtime") == "/etc/zoneinfo/Utc"
35 with subtest("/etc/mtab points to the right file"):
36 assert "/proc/mounts" == machine.succeed("readlink --no-newline /etc/mtab")
38 with subtest("Correct mode on the source password files"):
39 assert machine.succeed("stat -c '%a' /var/lib/nixos/etc/passwd") == "644\n"
40 assert machine.succeed("stat -c '%a' /var/lib/nixos/etc/group") == "644\n"
41 assert machine.succeed("stat -c '%a' /var/lib/nixos/etc/shadow") == "0\n"
42 assert machine.succeed("stat -c '%a' /var/lib/nixos/etc/gshadow") == "0\n"
44 with subtest("Password files are symlinks to /var/lib/nixos/etc"):
45 assert machine.succeed("readlink -f /etc/passwd") == "/var/lib/nixos/etc/passwd\n"
46 assert machine.succeed("readlink -f /etc/group") == "/var/lib/nixos/etc/group\n"
47 assert machine.succeed("readlink -f /etc/shadow") == "/var/lib/nixos/etc/shadow\n"
48 assert machine.succeed("readlink -f /etc/gshadow") == "/var/lib/nixos/etc/gshadow\n"
50 with subtest("switching to the same generation"):
51 machine.succeed("/run/current-system/bin/switch-to-configuration test")
53 with subtest("switching to a new generation"):
54 machine.fail("stat /etc/newgen")
56 machine.succeed("mount -t tmpfs tmpfs /etc/mountpoint")
57 machine.succeed("touch /etc/mountpoint/extra-file")
58 machine.succeed("mount --bind /dev/null /etc/filemount")
60 machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch")
62 assert machine.succeed("cat /etc/newgen") == "newgen"
64 print(machine.succeed("findmnt /etc/mountpoint"))
65 print(machine.succeed("ls /etc/mountpoint"))
66 print(machine.succeed("stat /etc/mountpoint/extra-file"))
67 print(machine.succeed("findmnt /etc/filemount"))