Skip to content

Commit

Permalink
Install from closure: wording and fallback using .bash_profile
Browse files Browse the repository at this point in the history
- use empty ~/.bash_profile if it's not there
- use "source" instead of vague "."
- make it explicit how to start using Nix after installation
  • Loading branch information
domenkozar committed Jan 25, 2017
1 parent 9000150 commit 1a65d81
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions scripts/install-nix-from-closure.sh
Expand Up @@ -90,43 +90,36 @@ if [ -z "$_NIX_INSTALLER_TEST" ]; then
fi

added=
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
# Make the shell source nix.sh during login.
p=$HOME/.nix-profile/etc/profile.d/nix.sh

if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
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 "$0: modifying $fn..." >&2
echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> "$fn"
fi
added=1
break
fi
done

fi

if [ -z "$added" ]; then
cat >&2 <<EOF
Installation finished! To ensure that the necessary environment
variables are set, please add the line
. $p
touch ~/.bash_profile
chmod +x ~/.bash_profile
echo "$0: modifying ~/.bash_profile..." >&2
echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> /.bash_profile
fi

to your shell profile (e.g. ~/.profile).
EOF
else
cat >&2 <<EOF
cat >&2 <<EOF
Installation has finished successfully.
Installation finished! To ensure that the necessary environment
variables are set, either log in again, or type
To start using Nix run:
. $p
$ source $p
in your shell.
EOF
fi

0 comments on commit 1a65d81

Please sign in to comment.