From 56203bca4e15c069d78af349a68b88bb71e978a6 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sun, 24 Nov 2024 20:30:17 +0000 Subject: [PATCH] nixos-rebuild-ng: add allow_tty parameter to process.run_wrapper --- .../ni/nixos-rebuild-ng/src/nixos_rebuild/process.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py index dc738bd17285..1bdc7d95e36f 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py @@ -22,6 +22,7 @@ def run_wrapper( check: bool, # make it explicit so we always know if the code is handling errors env: dict[str, str] | None = None, # replaces the current environment extra_env: dict[str, str] | None = None, # appends to the current environment + allow_tty: bool = True, remote: Ssh | None = None, sudo: bool = False, **kwargs: Unpack[RunKwargs], @@ -34,7 +35,15 @@ def run_wrapper( args = ["env", *extra_env_args, *args] if sudo: args = ["sudo", *args] - if remote.tty: + if allow_tty: + # SSH's TTY will redirect all output to stdout, that may cause + # unwanted effects when used + assert not kwargs.get( + "capture_output" + ), "SSH's TTY is incompatible with capture_output" + assert not kwargs.get("stderr"), "SSH's TTY is incompatible with stderr" + assert not kwargs.get("stdout"), "SSH's TTY is incompatible with stdout" + if allow_tty and remote.tty: args = ["ssh", "-t", *remote.opts, remote.host, "--", *args] else: args = ["ssh", *remote.opts, remote.host, "--", *args]