diff options
-rw-r--r-- | doc/manual/installation/installing-binary.xml | 8 | ||||
-rw-r--r-- | scripts/install-nix-from-closure.sh | 30 |
2 files changed, 25 insertions, 13 deletions
diff --git a/doc/manual/installation/installing-binary.xml b/doc/manual/installation/installing-binary.xml index da54e2bedd6f..2a9beec98c9b 100644 --- a/doc/manual/installation/installing-binary.xml +++ b/doc/manual/installation/installing-binary.xml @@ -26,6 +26,14 @@ $ mkdir /nix $ chown alice /nix </screen> +The install script will modify the first writable file from amongst +<filename>.bash_profile</filename>, <filename>.bash_login</filename> +and <filename>.profile</filename> to source +<filename>~/.nix-profile/etc/profile.d/nix.sh</filename>. You can set +the <command>NIX_INSTALLER_NO_MODIFY_PROFILE</command> environment +variable before executing the install script to disable this +behaviour. + </para> <!-- diff --git a/scripts/install-nix-from-closure.sh b/scripts/install-nix-from-closure.sh index 3b8c97ed26a1..fd38a4528cd7 100644 --- a/scripts/install-nix-from-closure.sh +++ b/scripts/install-nix-from-closure.sh @@ -89,21 +89,25 @@ if [ -z "$_NIX_INSTALLER_TEST" ]; then $nix/bin/nix-channel --update nixpkgs fi -# Make the shell source nix.sh during login. -p=$HOME/.nix-profile/etc/profile.d/nix.sh - added= -for i in .bash_profile .bash_login .profile; do - fn="$HOME/$i" - if [ -w "$fn" ]; then - if ! grep -q "$p" "$fn"; then - echo "modifying $fn..." >&2 - echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> $fn +if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then + + # Make the shell source nix.sh during login. + p=$HOME/.nix-profile/etc/profile.d/nix.sh + + for i in .bash_profile .bash_login .profile; do + fn="$HOME/$i" + if [ -w "$fn" ]; then + if ! grep -q "$p" "$fn"; then + echo "modifying $fn..." >&2 + echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> $fn + fi + added=1 + break fi - added=1 - break - fi -done + done + +fi if [ -z "$added" ]; then cat >&2 <<EOF |