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:
parent
fd510a7122
commit
32814a6eb1
1 changed files with 4 additions and 3 deletions
|
@ -99,6 +99,10 @@ in
|
||||||
assertion = cfg.users ? root -> (cfg.users.root.home == null || cfg.users.root.home == "/var/root");
|
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`.";
|
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;
|
users.gids = mkMerge gids;
|
||||||
|
@ -194,9 +198,6 @@ in
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
printf >&2 '\e[1;31merror: refusing to delete the user calling `darwin-rebuild` (%s), aborting activation\e[0m\n', ${name}
|
printf >&2 '\e[1;31merror: refusing to delete the user calling `darwin-rebuild` (%s), aborting activation\e[0m\n', ${name}
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ ${name} == "root" ]]; then
|
|
||||||
printf >&2 '\e[1;31merror: refusing to delete `root`, aborting activation\e[0m\n'
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ensurePerms ${name} delete
|
ensurePerms ${name} delete
|
||||||
|
|
Loading…
Reference in a new issue