aboutsummaryrefslogtreecommitdiff
path: root/scripts/install-nix-from-closure.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/install-nix-from-closure.sh')
-rw-r--r--scripts/install-nix-from-closure.sh39
1 files changed, 32 insertions, 7 deletions
diff --git a/scripts/install-nix-from-closure.sh b/scripts/install-nix-from-closure.sh
index d543b4463..ccd19e1a8 100644
--- a/scripts/install-nix-from-closure.sh
+++ b/scripts/install-nix-from-closure.sh
@@ -71,6 +71,8 @@ while [ $# -gt 0 ]; do
# # intentional tail space
# ACTIONS="${ACTIONS}uninstall "
# ;;
+ --yes)
+ export NIX_INSTALLER_YES=1;;
--no-channel-add)
export NIX_INSTALLER_NO_CHANNEL_ADD=1;;
--daemon-user-count)
@@ -90,7 +92,7 @@ while [ $# -gt 0 ]; do
shift;;
*)
{
- echo "Nix Installer [--daemon|--no-daemon] [--daemon-user-count INT] [--no-channel-add] [--no-modify-profile] [--nix-extra-conf-file FILE]"
+ echo "Nix Installer [--daemon|--no-daemon] [--daemon-user-count INT] [--yes] [--no-channel-add] [--no-modify-profile] [--nix-extra-conf-file FILE]"
echo "Choose installation method."
echo ""
@@ -104,6 +106,8 @@ while [ $# -gt 0 ]; do
echo " trivial to uninstall."
echo " (default)"
echo ""
+ echo " --yes: Run the script non-interactively, accepting all prompts."
+ echo ""
echo " --no-channel-add: Don't add any channels. nixpkgs-unstable is installed by default."
echo ""
echo " --no-modify-profile: Don't modify the user profile to automatically load nix."
@@ -148,7 +152,9 @@ if ! [ -w "$dest" ]; then
exit 1
fi
-mkdir -p "$dest/store"
+# The auto-chroot code in openFromNonUri() checks for the
+# non-existence of /nix/var/nix, so we need to create it here.
+mkdir -p "$dest/store" "$dest/var/nix"
printf "copying Nix to %s..." "${dest}/store" >&2
# Insert a newline if no progress is shown.
@@ -207,31 +213,50 @@ if [ -z "$NIX_INSTALLER_NO_CHANNEL_ADD" ]; then
fi
added=
-p=$HOME/.nix-profile/etc/profile.d/nix.sh
+p=
+p_sh=$HOME/.nix-profile/etc/profile.d/nix.sh
+p_fish=$HOME/.nix-profile/etc/profile.d/nix.fish
if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
# Make the shell source nix.sh during login.
for i in .bash_profile .bash_login .profile; do
fn="$HOME/$i"
if [ -w "$fn" ]; then
- if ! grep -q "$p" "$fn"; then
+ if ! grep -q "$p_sh" "$fn"; then
echo "modifying $fn..." >&2
- printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p" "$p" >> "$fn"
+ printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p_sh" "$p_sh" >> "$fn"
fi
added=1
+ p=${p_sh}
break
fi
done
for i in .zshenv .zshrc; do
fn="$HOME/$i"
if [ -w "$fn" ]; then
- if ! grep -q "$p" "$fn"; then
+ if ! grep -q "$p_sh" "$fn"; then
echo "modifying $fn..." >&2
- printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p" "$p" >> "$fn"
+ printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p_sh" "$p_sh" >> "$fn"
fi
added=1
+ p=${p_sh}
break
fi
done
+
+ if [ -d "$HOME/.config/fish" ]; then
+ fishdir=$HOME/.config/fish/conf.d
+ if [ ! -d "$fishdir" ]; then
+ mkdir -p "$fishdir"
+ fi
+
+ fn="$fishdir/nix.fish"
+ echo "placing $fn..." >&2
+ printf '\nif test -e %s; . %s; end # added by Nix installer\n' "$p_fish" "$p_fish" > "$fn"
+ added=1
+ p=${p_fish}
+ fi
+else
+ p=${p_sh}
fi
if [ -z "$added" ]; then