mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
installation: allow profile modification to be skipped (#1072)
The current behaviour modifies the first writeable file from amongst .bash_profile, .bash_login and .profile. So .bash_profile (if it is writable) would be modified even if a user has already sourced nix.sh in, say, .profile. This commit introduces a new environment variable, NIX_INSTALLER_NO_MODIFY_PROFILE. If this is set during installation, then the modifications are unconditionally skipped. This is useful for users who have a manually curated set of dotfiles that they are porting to a new machine. In such scenarios, nix.sh is already sourced at a place where the user prefers. Without this change, the nix installer would insist on modifying .bash_profile if it exists. This commit also add documentations for both the current behaviour and the new override.
This commit is contained in:
parent
18b7363a69
commit
eec5409a69
2 changed files with 25 additions and 13 deletions
|
@ -26,6 +26,14 @@ $ mkdir /nix
|
||||||
$ chown alice /nix
|
$ chown alice /nix
|
||||||
</screen>
|
</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>
|
</para>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
|
@ -89,21 +89,25 @@ if [ -z "$_NIX_INSTALLER_TEST" ]; then
|
||||||
$nix/bin/nix-channel --update nixpkgs
|
$nix/bin/nix-channel --update nixpkgs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make the shell source nix.sh during login.
|
|
||||||
p=$HOME/.nix-profile/etc/profile.d/nix.sh
|
|
||||||
|
|
||||||
added=
|
added=
|
||||||
for i in .bash_profile .bash_login .profile; do
|
if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
|
||||||
fn="$HOME/$i"
|
|
||||||
if [ -w "$fn" ]; then
|
# Make the shell source nix.sh during login.
|
||||||
if ! grep -q "$p" "$fn"; then
|
p=$HOME/.nix-profile/etc/profile.d/nix.sh
|
||||||
echo "modifying $fn..." >&2
|
|
||||||
echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> $fn
|
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
|
fi
|
||||||
added=1
|
done
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z "$added" ]; then
|
if [ -z "$added" ]; then
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
|
|
Loading…
Reference in a new issue