Skip to content

Commit

Permalink
nixos-rebuild: Add tty only to "sudo-able" commands for target
Browse files Browse the repository at this point in the history
This solves again the problem solved by 09fd207.

To quote:

> We always want to use `ssh -t` to force PTY allocation as there may be
> interactive SSH prompts like trusting unknown hosts.

However, the creation of a pseudoterminal causes the remote stdout and stderr
to point to the same tty, resulting in a single stream in the ssh client,
which breaks other usages of ssh, such as `--build-host`.

Hence, this commit only sets the flag for invocations that need it -
or would need it if sudo were disabled. That should help with development
and gives a somewhat more consistent user experience.
  • Loading branch information
roberth committed Jan 14, 2024
1 parent 99d3e0c commit 472dfb3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ targetHostCmd() {

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

0 comments on commit 472dfb3

Please sign in to comment.