Skip to content

Commit 5df7d8b

Browse files
committed
feat(nix): prompt before falling back to single-user mode
When multi-user installation fails (e.g., user declines sudo), ask whether to continue with single-user installation instead of silently falling back.
1 parent 1df68a2 commit 5df7d8b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

nix/install.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,23 @@ install_nix() {
4848
fi
4949
else
5050
# Try official installer with multi-user mode first
51-
if ! curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install | sh -s -- --daemon --yes --nix-extra-conf-file "$extra_conf"; then
52-
# Fallback to single-user mode
53-
if ! curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install | sh -s -- --no-daemon --yes --nix-extra-conf-file "$extra_conf"; then
54-
die "Nix installation failed"
55-
fi
51+
if curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install | sh -s -- --daemon --yes --nix-extra-conf-file "$extra_conf"; then
52+
: # success
53+
else
54+
echo ""
55+
echo "Multi-user installation failed (requires sudo)."
56+
printf "Continue with single-user installation? [y/N]: "
57+
read -r choice < /dev/tty || choice=""
58+
case "$choice" in
59+
y|Y)
60+
if ! curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install | sh -s -- --no-daemon --yes --nix-extra-conf-file "$extra_conf"; then
61+
die "Nix installation failed"
62+
fi
63+
;;
64+
*)
65+
die "Installation aborted"
66+
;;
67+
esac
5668
fi
5769
fi
5870

0 commit comments

Comments
 (0)