lol

nixos/tests: Add a test for config.users.mutableUsers.

It's in preparation to add an assertion for #4990.

+39
+39
nixos/tests/mutable-users.nix
···
··· 1 + # Mutable users tests. 2 + 3 + import ./make-test.nix ({ pkgs, ...} : { 4 + name = "mutable-users"; 5 + meta = with pkgs.stdenv.lib.maintainers; { 6 + maintainers = [ gleber ]; 7 + }; 8 + 9 + nodes = { 10 + machine = { config, lib, pkgs, ... }: { 11 + users.mutableUsers = false; 12 + }; 13 + mutable = { config, lib, pkgs, ... }: { 14 + users.mutableUsers = true; 15 + }; 16 + }; 17 + 18 + testScript = {nodes, ...}: let 19 + immutableSystem = nodes.machine.config.system.build.toplevel; 20 + mutableSystem = nodes.mutable.config.system.build.toplevel; 21 + in '' 22 + $machine->start(); 23 + $machine->waitForUnit("default.target"); 24 + 25 + # Machine starts in immutable mode. Add a user and test if reactivating 26 + # configuration removes the user. 27 + $machine->fail("cat /etc/passwd | grep ^foobar:"); 28 + $machine->succeed("sudo useradd foobar"); 29 + $machine->succeed("cat /etc/passwd | grep ^foobar:"); 30 + $machine->succeed("${immutableSystem}/bin/switch-to-configuration test"); 31 + $machine->fail("cat /etc/passwd | grep ^foobar:"); 32 + 33 + # In immutable mode passwd is not wrapped, while in mutable mode it is 34 + # wrapped. 35 + $machine->succeed('which passwd | grep /run/current-system/'); 36 + $machine->succeed("${mutableSystem}/bin/switch-to-configuration test"); 37 + $machine->succeed('which passwd | grep /run/wrappers/'); 38 + ''; 39 + })