From 3eda6b34789f6f1841f2753950f3f11bb1abb27f Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 27 Mar 2021 20:25:31 +0100 Subject: runShell/writeCommand: add allocateTTY argument --- README.md | 4 ++++ pkgs/krops/default.nix | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6648fa0..9b1e2a8 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,10 @@ pkgs.krops.writeCommand "deploy-with-swap" { [see `writeDeploy`](#writeDeploy) +### `allocateTTY` (optional, defaults to false) + +whether the ssh session should do a pseudo-terminal allocation. +sets `-t` on the ssh command. ## Source Types diff --git a/pkgs/krops/default.nix b/pkgs/krops/default.nix index 8336b51..e94b68f 100644 --- a/pkgs/krops/default.nix +++ b/pkgs/krops/default.nix @@ -5,7 +5,7 @@ in { nix, openssh, populate, writers }: rec { build = target: - runShell target (lib.concatStringsSep " " [ + runShell target {} (lib.concatStringsSep " " [ "nix build" "-I ${lib.escapeShellArg target.path}" "--no-link -f ''" @@ -13,11 +13,13 @@ in ]); rebuild = args: target: - runShell target "nixos-rebuild -I ${lib.escapeShellArg target.path} ${ + runShell target {} "nixos-rebuild -I ${lib.escapeShellArg target.path} ${ lib.concatMapStringsSep " " lib.escapeShellArg args }"; - runShell = target: command: + runShell = target: { + allocateTTY ? false + }: command: let command' = if target.sudo then "sudo ${command}" else command; in @@ -28,7 +30,7 @@ in exec ${openssh}/bin/ssh ${lib.escapeShellArgs (lib.flatten [ (lib.optionals (target.user != "") ["-l" target.user]) "-p" target.port - "-T" + (if allocateTTY then "-t" else "-T") target.extraOptions target.host command'])} @@ -38,6 +40,7 @@ in command ? (targetPath: "echo ${targetPath}"), backup ? false, force ? false, + allocateTTY ? false, source, target }: let @@ -46,7 +49,7 @@ in writers.writeDash name '' set -efu ${populate { inherit backup force source; target = target'; }} - ${runShell target' (command target'.path)} + ${runShell target' { inherit allocateTTY; } (command target'.path)} ''; writeDeploy = name: { -- cgit v1.2.3