From 2c09cfc097daef5b85d21fe906441b5702bb2101 Mon Sep 17 00:00:00 2001 From: Bjørn Forsman Date: Wed, 23 Oct 2019 20:22:39 +0200 Subject: nixos-rebuild: add explicit option to enable (remote) sudo Add --use-remote-sudo option. When set, remote commands will be prefixed with 'sudo'. This allows using sudo remotely _without_ having to use sudo locally (when using --build-host/--taget-host). --- nixos/modules/installer/tools/nixos-rebuild.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'nixos/modules') diff --git a/nixos/modules/installer/tools/nixos-rebuild.sh b/nixos/modules/installer/tools/nixos-rebuild.sh index 891f374df536..c53dc1000c4a 100644 --- a/nixos/modules/installer/tools/nixos-rebuild.sh +++ b/nixos/modules/installer/tools/nixos-rebuild.sh @@ -90,6 +90,11 @@ while [ "$#" -gt 0 ]; do targetHost="$1" shift 1 ;; + --use-remote-sudo) + # note the trailing space + maybeSudo="sudo " + shift 1 + ;; *) echo "$0: unknown option \`$i'" exit 1 @@ -97,10 +102,6 @@ while [ "$#" -gt 0 ]; do esac done -if [ -n "$SUDO_USER" ]; then - maybeSudo="sudo " -fi - if [ -z "$buildHost" -a -n "$targetHost" ]; then buildHost="$targetHost" fi -- cgit 1.4.1