1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

users: replace runtime check to prevent deleting root with assertion

This fixes SC2050 as `${name} == "root"` will be generated as a constant
expression.
This commit is contained in:
Michael Hoang 2024-11-01 00:38:47 +11:00
parent fd510a7122
commit 32814a6eb1

View file

@ -99,6 +99,10 @@ in
assertion = cfg.users ? root -> (cfg.users.root.home == null || cfg.users.root.home == "/var/root");
message = "`users.users.root.home` must be set to either `null` or `/var/root`.";
}
{
assertion = !builtins.elem "root" deletedUsers;
message = "Remove `root` from `users.knownUsers` if you no longer want nix-darwin to manage it.";
}
];
users.gids = mkMerge gids;
@ -194,9 +198,6 @@ in
# shellcheck disable=SC2016
printf >&2 '\e[1;31merror: refusing to delete the user calling `darwin-rebuild` (%s), aborting activation\e[0m\n', ${name}
exit 1
elif [[ ${name} == "root" ]]; then
printf >&2 '\e[1;31merror: refusing to delete `root`, aborting activation\e[0m\n'
exit 1
fi
ensurePerms ${name} delete