mirror of
https://github.com/NixOS/nix.git
synced 2024-11-25 16:23:02 +00:00
install: Allow to specify alternative sudo
command
This commit is contained in:
parent
059bdb5a64
commit
b18d6b1fa8
@ -56,6 +56,9 @@ readonly NIX_INSTALLED_CACERT="@cacert@"
|
|||||||
#readonly NIX_INSTALLED_CACERT="/nix/store/7dxhzymvy330i28ii676fl1pqwcahv2f-nss-cacert-3.49.2"
|
#readonly NIX_INSTALLED_CACERT="/nix/store/7dxhzymvy330i28ii676fl1pqwcahv2f-nss-cacert-3.49.2"
|
||||||
readonly EXTRACTED_NIX_PATH="$(dirname "$0")"
|
readonly EXTRACTED_NIX_PATH="$(dirname "$0")"
|
||||||
|
|
||||||
|
# allow to override identity change command
|
||||||
|
readonly NIX_BECOME=${NIX_BECOME:-sudo}
|
||||||
|
|
||||||
readonly ROOT_HOME=~root
|
readonly ROOT_HOME=~root
|
||||||
|
|
||||||
if [ -t 0 ] && [ -z "${NIX_INSTALLER_YES:-}" ]; then
|
if [ -t 0 ] && [ -z "${NIX_INSTALLER_YES:-}" ]; then
|
||||||
@ -123,7 +126,7 @@ uninstall_directions() {
|
|||||||
cat <<EOF
|
cat <<EOF
|
||||||
$step. Restore $profile_target$PROFILE_BACKUP_SUFFIX back to $profile_target
|
$step. Restore $profile_target$PROFILE_BACKUP_SUFFIX back to $profile_target
|
||||||
|
|
||||||
sudo mv $profile_target$PROFILE_BACKUP_SUFFIX $profile_target
|
$NIX_BECOME mv $profile_target$PROFILE_BACKUP_SUFFIX $profile_target
|
||||||
|
|
||||||
(after this one, you may need to re-open any terminals that were
|
(after this one, you may need to re-open any terminals that were
|
||||||
opened while it existed.)
|
opened while it existed.)
|
||||||
@ -136,7 +139,7 @@ EOF
|
|||||||
cat <<EOF
|
cat <<EOF
|
||||||
$step. Delete the files Nix added to your system:
|
$step. Delete the files Nix added to your system:
|
||||||
|
|
||||||
sudo rm -rf "/etc/nix" "$NIX_ROOT" "$ROOT_HOME/.nix-profile" "$ROOT_HOME/.nix-defexpr" "$ROOT_HOME/.nix-channels" "$ROOT_HOME/.local/state/nix" "$ROOT_HOME/.cache/nix" "$HOME/.nix-profile" "$HOME/.nix-defexpr" "$HOME/.nix-channels" "$HOME/.local/state/nix" "$HOME/.cache/nix"
|
$NIX_BECOME rm -rf "/etc/nix" "$NIX_ROOT" "$ROOT_HOME/.nix-profile" "$ROOT_HOME/.nix-defexpr" "$ROOT_HOME/.nix-channels" "$ROOT_HOME/.local/state/nix" "$ROOT_HOME/.cache/nix" "$HOME/.nix-profile" "$HOME/.nix-defexpr" "$HOME/.nix-channels" "$HOME/.local/state/nix" "$HOME/.cache/nix"
|
||||||
|
|
||||||
and that is it.
|
and that is it.
|
||||||
|
|
||||||
@ -343,7 +346,7 @@ __sudo() {
|
|||||||
|
|
||||||
echo "I am executing:"
|
echo "I am executing:"
|
||||||
echo ""
|
echo ""
|
||||||
printf " $ sudo %s\\n" "$cmd"
|
printf " $ $NIX_BECOME %s\\n" "$cmd"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$expl"
|
echo "$expl"
|
||||||
echo ""
|
echo ""
|
||||||
@ -361,7 +364,9 @@ _sudo() {
|
|||||||
if is_root; then
|
if is_root; then
|
||||||
env "$@"
|
env "$@"
|
||||||
else
|
else
|
||||||
sudo "$@"
|
# env sets environment variables for sudo alternatives
|
||||||
|
# that don't support "VAR=value command" syntax
|
||||||
|
$NIX_BECOME env "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user