diff options
-rwxr-xr-x | pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh index 1b7ec45ae2d32..006b5db6320c5 100755 --- a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh +++ b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh @@ -177,20 +177,34 @@ runCmd() { } buildHostCmd() { + local c + if [[ "${useSudo:-x}" = 1 ]]; then + c=("${sudoCommand[@]}") + else + c=() + fi + if [ -z "$buildHost" ]; then runCmd "$@" elif [ -n "$remoteNix" ]; then - runCmd ssh $SSHOPTS "$buildHost" "${useSudo:+${sudoCommand[@]}}" env PATH="$remoteNix":'$PATH' "$@" + runCmd ssh $SSHOPTS "$buildHost" "${c[@]}" env PATH="$remoteNix":'$PATH' "$@" else - runCmd ssh $SSHOPTS "$buildHost" "${useSudo:+${sudoCommand[@]}}" "$@" + runCmd ssh $SSHOPTS "$buildHost" "${c[@]}" "$@" fi } targetHostCmd() { + local c + if [[ "${useSudo:-x}" = 1 ]]; then + c=("${sudoCommand[@]}") + else + c=() + fi + if [ -z "$targetHost" ]; then - runCmd "${useSudo:+${sudoCommand[@]}}" "$@" + runCmd "${c[@]}" "$@" else - runCmd ssh $SSHOPTS "$targetHost" "${useSudo:+${sudoCommand[@]}}" "$@" + runCmd ssh $SSHOPTS "$targetHost" "${c[@]}" "$@" fi } |