1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

Allow sudo alternatives when installing from tarball

This commit is contained in:
Anatoli Babenia 2024-11-23 09:51:56 +03:00
parent 04975f7c32
commit e83481f5a8

View file

@ -9,6 +9,8 @@ self="$(dirname "$0")"
nix="@nix@"
cacert="@cacert@"
# allow to override identity change command
readonly NIX_BECOME="${NIX_BECOME:-sudo}"
if ! [ -e "$self/.reginfo" ]; then
echo "$0: incomplete installer (.reginfo is missing)" >&2
@ -63,7 +65,6 @@ while [ $# -gt 0 ]; do
exit 1
fi
INSTALL_MODE=no-daemon
# intentional tail space
ACTION=install
;;
--yes)
@ -135,8 +136,8 @@ echo "performing a single-user installation of Nix..." >&2
if ! [ -e "$dest" ]; then
cmd="mkdir -m 0755 $dest && chown $USER $dest"
echo "directory $dest does not exist; creating it by running '$cmd' using sudo" >&2
if ! sudo sh -c "$cmd"; then
echo "directory $dest does not exist; creating it by running '$cmd' using $NIX_BECOME" >&2
if ! $NIX_BECOME sh -c "$cmd"; then
echo "$0: please manually run '$cmd' as root to create $dest" >&2
exit 1
fi