primary-user: init

This commit is contained in:
Emily 2025-01-11 15:44:41 +00:00
parent 8817b00b00
commit 52ee8c57c2
3 changed files with 75 additions and 0 deletions

View file

@ -31,6 +31,19 @@ let
fi
'';
primaryUser = ''
# shellcheck disable=SC2209
primaryUser=${escapeShellArg config.system.primaryUser}
if ! id -- "$primaryUser" >/dev/null 2>&1; then
printf >&2 '\e[1;31merror: primary user `%s` does not exist, aborting activation\e[0m\n' \
"$primaryUser"
printf >&2 'Please ensure that `system.primaryUser` is set to the name of an\n'
printf >&2 'existing user. Usually this should be the user you have been using to\n'
printf >&2 'run `darwin-rebuild`.\n'
exit 2
fi
'';
determinate = ''
if [[ -e /usr/local/bin/determinate-nixd ]]; then
printf >&2 '\e[1;31merror: Determinate detected, aborting activation\e[0m\n'
@ -275,6 +288,7 @@ in
system.checks.text = mkMerge [
(mkIf cfg.verifyMacOSVersion macOSVersion)
(mkIf (config.system.primaryUser != null) primaryUser)
(mkIf config.nix.enable determinate)
(mkIf cfg.verifyBuildUsers preSequoiaBuildUsers)
(mkIf cfg.verifyBuildUsers buildGroupID)