diff --git a/bootstrap.sh b/bootstrap.sh index d2bc5d3a..277bbe6d 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -211,12 +211,6 @@ install(){ fi fi - if grep -q 'etc/profile.d/nix-daemon.sh' /etc/profile; then - echo -e ""$RED"WARNING: Detected nix-daemon.sh in /etc/profile." - echo "This will override environment variables configured by nix-darwin," - echo "you might want to remove that." - fi - # Finish echo -e ""$GREEN"You're all done!"$ESC"" echo -e "Take a look at "$YELLOW"~/.nixpkgs/darwin-configuration.nix"$ESC" to get started." diff --git a/modules/system/activation-checks.nix b/modules/system/activation-checks.nix index bddaa473..0379e0b7 100644 --- a/modules/system/activation-checks.nix +++ b/modules/system/activation-checks.nix @@ -53,6 +53,22 @@ let esac ''; + nixInstaller = '' + if grep -q 'etc/profile.d/nix-daemon.sh' /etc/profile; then + echo "error: Found nix-daemon.sh reference in /etc/profile, aborting activation" >&2 + echo "This will override options like nix.nixPath because it runs later," >&2 + echo "remove this snippet from /etc/profile:" >&2 + echo >&2 + echo " # Nix" >&2 + echo " if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then" >&2 + echo " . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'" >&2 + echo " fi" >&2 + echo " # End Nix" >&2 + echo >&2 + exit 2 + fi + ''; + nixPath = '' darwinConfig=$(NIX_PATH=${concatStringsSep ":" config.nix.nixPath} nix-instantiate --eval -E '' || echo '$HOME/.nixpkgs/darwin-configuration.nix') || true if ! test -e "$darwinConfig"; then @@ -104,6 +120,7 @@ in ${darwinChanges} ${buildUsers} ${nixChannels} + ${nixInstaller} ${nixPath} if test ''${checkActivation:-0} -eq 1; then