Unverified Commit 48ffcd69 authored by Robert Hensing's avatar Robert Hensing Committed by GitHub
Browse files

Merge pull request #280842 from hercules-ci/regression-277642

nixos-rebuild: Fix regression from #277642
parents 97684f54 c8c3c585
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -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
}

@@ -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.