aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-13 14:01:28 +0000
committertv <tv@krebsco.de>2026-11-13 15:07:23 +0100
commitafdb3ee5fe6e6ce2447f4838ca88108525b0ee4b (patch)
treef88feea397764c8bd86bce7e9141b1eb1790f100 /pkgs
parent36cfd6b9fa8d729172f90e8fdd507349905d4f11 (diff)
krops: add allocateTTY to writeDeploy
With allocateTTY, nixos-rebuild runs with a terminal, so it shows colours and progress: on remote targets, ssh gets -t, which allocates a terminal if its own input is one, and on the local target, expect's unbuffer provides one. The nixos-rebuild stand-in records whether its output is a terminal.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/krops/default.nix11
1 files changed, 8 insertions, 3 deletions
diff --git a/pkgs/krops/default.nix b/pkgs/krops/default.nix
index ac2d9a2..d33bcb5 100644
--- a/pkgs/krops/default.nix
+++ b/pkgs/krops/default.nix
@@ -2,9 +2,10 @@ let
lib = import ../../lib;
in
-{ nix, openssh, populate, writers }: rec {
+{ expect, nix, openssh, populate, writers }: rec {
rebuild = {
+ allocateTTY ? false,
flake ? null,
useNixOutputMonitor
}:
@@ -14,7 +15,7 @@ in
flakeDir = lib.head (lib.splitString "#" flake);
flakeAttr = lib.removePrefix flakeDir flake;
in
- runShell target {}
+ runShell target { inherit allocateTTY; }
(withNixOutputMonitor target useNixOutputMonitor /* sh */ ''
${lib.optionalString (flake != null) /* sh */ ''
${lib.shell.requireFlakes "deploying a flake"}
@@ -35,6 +36,9 @@ in
fi
''}
NIX_PATH=${lib.escapeShellArg target.path} \
+ ${lib.optionalString (allocateTTY && lib.isLocalTarget target)
+ # Without ssh, which allocates the terminal on remote targets.
+ "${expect}/bin/unbuffer"} \
nixos-rebuild ${lib.escapeShellArgs args} ${
if flake != null then
''--flake "$flake"${lib.escapeShellArg flakeAttr}''
@@ -119,6 +123,7 @@ in
'';
writeDeploy = name: {
+ allocateTTY ? false,
backup ? false,
buildTarget ? null,
crossDeploy ? false,
@@ -159,7 +164,7 @@ in
${lib.optionalString (buildTarget' != target')
(populate { inherit backup force prune source; target = buildTarget'; })}
${populate { inherit backup force prune source; target = target'; }}
- ${rebuild { flake = flake'; inherit useNixOutputMonitor; } ([
+ ${rebuild { flake = flake'; inherit allocateTTY useNixOutputMonitor; } ([
operation
] ++ lib.optionals crossDeploy [
"--no-build-nix"