Install from closure: wording and fallback using .bash_profile

- use empty ~/.bash_profile if it's not there
- use "source" instead of vague "."
- make it explicit how to start using Nix after installation
This commit is contained in:
Domen Kožar 2017-01-25 18:03:50 +01:00
parent 9000150a78
commit 02ea337a36
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246

View file

@ -90,43 +90,37 @@ if [ -z "$_NIX_INSTALLER_TEST" ]; then
fi fi
added= added=
# 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 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 for i in .bash_profile .bash_login .profile; do
fn="$HOME/$i" fn="$HOME/$i"
if [ -w "$fn" ]; then if [ -w "$fn" ]; then
if ! grep -q "$p" "$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" echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> "$fn"
fi fi
added=1 added=1
break break
fi fi
done done
fi fi
if [ -z "$added" ]; then if [ -z "$added" ]; then
cat >&2 <<EOF echo "$0: creating ~/.bash_profile ..." >&2
touch ~/.bash_profile
Installation finished! To ensure that the necessary environment chmod +x ~/.bash_profile
variables are set, please add the line echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> /.bash_profile
. $p
to your shell profile (e.g. ~/.profile).
EOF
else
cat >&2 <<EOF
Installation finished! To ensure that the necessary environment
variables are set, either log in again, or type
. $p
in your shell.
EOF
fi fi
cat >&2 <<EOF
Installation has finished successfully.
To start using Nix, execute in your shell:
$ source $p
EOF