1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-17 19:21:04 +00:00
nixpkgs/nixos/tests/userborn-immutable-etc.nix
2024-08-26 12:45:33 +02:00

71 lines
1.7 KiB
Nix

{ lib, ... }:
let
normaloHashedPassword = "$y$j9T$IEWqhKtWg.r.8fVkSEF56.$iKNxdMC6hOAQRp6eBtYvBk4c7BGpONXeZMqc8I/LM46";
common = {
services.userborn.enable = true;
boot.initrd.systemd.enable = true;
system.etc.overlay = {
enable = true;
mutable = false;
};
};
in
{
name = "userborn-immutable-etc";
meta.maintainers = with lib.maintainers; [ nikstur ];
nodes.machine =
{ config, ... }:
{
imports = [ common ];
users = {
users = {
normalo = {
isNormalUser = true;
hashedPassword = normaloHashedPassword;
};
};
};
specialisation.new-generation = {
inheritParentConfig = false;
configuration = {
nixpkgs = {
inherit (config.nixpkgs) hostPlatform;
};
imports = [ common ];
users.users = {
new-normalo = {
isNormalUser = true;
};
};
};
};
};
testScript = ''
machine.wait_for_unit("userborn.service")
with subtest("normalo user is created"):
assert "${normaloHashedPassword}" in machine.succeed("getent shadow normalo"), "normalo user password is not correct"
machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch")
with subtest("normalo user is disabled"):
print(machine.succeed("getent shadow normalo"))
assert "!*" in machine.succeed("getent shadow normalo"), "normalo user is not disabled"
with subtest("new-normalo user is created after switching to new generation"):
print(machine.succeed("getent passwd new-normalo"))
'';
}