Skip to content

Commit

Permalink
Merge pull request #280842 from hercules-ci/regression-277642
Browse files Browse the repository at this point in the history
nixos-rebuild: Fix regression from #277642
  • Loading branch information
roberth committed Jan 14, 2024
2 parents 97684f5 + c8c3c58 commit 48ffcd6
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,28 +177,44 @@ 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
}

targetHostSudoCmd() {
if [ -n "$remoteSudo" ]; then
useSudo=1 targetHostCmd "$@"
useSudo=1 SSHOPTS="$SSHOPTS -t" targetHostCmd "$@"
else
targetHostCmd "$@"
# While a tty might not be necessary, we apply it to be consistent with
# sudo usage, and an experience that is more consistent with local deployment.
SSHOPTS="$SSHOPTS -t" targetHostCmd "$@"
fi
}

Expand Down Expand Up @@ -436,7 +452,7 @@ if [ "$action" = edit ]; then
exit 1
fi

SSHOPTS="$NIX_SSHOPTS -o ControlMaster=auto -o ControlPath=$tmpDir/ssh-%n -o ControlPersist=60 -t"
SSHOPTS="$NIX_SSHOPTS -o ControlMaster=auto -o ControlPath=$tmpDir/ssh-%n -o ControlPersist=60"

# First build Nix, since NixOS may require a newer version than the
# current one.
Expand Down

0 comments on commit 48ffcd6

Please sign in to comment.