summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2021-03-27 20:25:31 +0100
committerlassulus <lassulus@lassul.us>2021-03-27 21:16:14 +0100
commit3eda6b34789f6f1841f2753950f3f11bb1abb27f (patch)
tree154ea351ec5c13d3e1631458213cefd9d32db214
parentcccebf3ff7a53336b3f106cb96dddd5892d427ed (diff)
runShell/writeCommand: add allocateTTY argumentinteractive
-rw-r--r--README.md4
-rw-r--r--pkgs/krops/default.nix13
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 '<nixpkgs/nixos>'"
@@ -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: {