Skip to content

Commit

Permalink
install: Allow to specify alternative sudo command
Browse files Browse the repository at this point in the history
  • Loading branch information
abitrolly committed Oct 28, 2024
1 parent 059bdb5 commit b18d6b1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scripts/install-multi-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ readonly NIX_INSTALLED_CACERT="@cacert@"
#readonly NIX_INSTALLED_CACERT="/nix/store/7dxhzymvy330i28ii676fl1pqwcahv2f-nss-cacert-3.49.2"
readonly EXTRACTED_NIX_PATH="$(dirname "$0")"

# allow to override identity change command
readonly NIX_BECOME=${NIX_BECOME:-sudo}

readonly ROOT_HOME=~root

if [ -t 0 ] && [ -z "${NIX_INSTALLER_YES:-}" ]; then
Expand Down Expand Up @@ -123,7 +126,7 @@ uninstall_directions() {
cat <<EOF
$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
opened while it existed.)
Expand All @@ -136,7 +139,7 @@ EOF
cat <<EOF
$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.
Expand Down Expand Up @@ -343,7 +346,7 @@ __sudo() {

echo "I am executing:"
echo ""
printf " $ sudo %s\\n" "$cmd"
printf " $ $NIX_BECOME %s\\n" "$cmd"
echo ""
echo "$expl"
echo ""
Expand All @@ -361,7 +364,9 @@ _sudo() {
if is_root; then
env "$@"
else
sudo "$@"
# env sets environment variables for sudo alternatives
# that don't support "VAR=value command" syntax
$NIX_BECOME env "$@"
fi
}

Expand Down

0 comments on commit b18d6b1

Please sign in to comment.