1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-05 16:27:03 +00:00

Merge pull request #1303 from emilazy/push-ulxuwyrnkwpq

{activation-scripts,activate-system}: purify environment
This commit is contained in:
Emily 2025-01-27 23:11:51 +00:00 committed by GitHub
commit 5c12a6f4a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 7 deletions

View file

@ -10,7 +10,14 @@
script = ''
set -e
set -o pipefail
export PATH="${pkgs.gnugrep}/bin:${pkgs.coreutils}/bin:@out@/sw/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export USER=root
export LOGNAME=root
export HOME=~root
export SHELL=$BASH
export LANG=C
export LC_CTYPE=UTF-8
systemConfig=$(cat ${config.system.profile}/systemConfig)
@ -28,7 +35,6 @@
${config.system.activationScripts.keyboard.text}
'';
serviceConfig.RunAtLoad = true;
serviceConfig.KeepAlive.SuccessfulExit = false;
};
};
}

View file

@ -37,19 +37,33 @@ in
config = {
system.activationScripts.script.text = ''
#! ${stdenv.shell}
#!/usr/bin/env -i ${stdenv.shell}
# shellcheck shell=bash
# shellcheck disable=SC2096
set -e
set -o pipefail
export PATH="${pkgs.gnugrep}/bin:${pkgs.coreutils}/bin:@out@/sw/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export USER=root
export LOGNAME=root
export HOME=~root
export SHELL=$BASH
export LANG=C
export LC_CTYPE=UTF-8
systemConfig=@out@
_status=0
trap "_status=1" ERR
# Ensure a consistent umask.
umask 0022
cd /
if [[ $(id -u) -ne 0 ]]; then
printf >&2 '\e[1;31merror: `activate` must be run as root\e[0m\n'
exit 2
fi
${cfg.activationScripts.preActivation.text}
# We run `etcChecks` again just in case someone runs `activate`
@ -82,8 +96,6 @@ in
# Prevent the current configuration from being garbage-collected.
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
exit $_status
'';
# FIXME: activationScripts.checks should be system level