summaryrefslogtreecommitdiffstats
path: root/krops.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-24 05:36:24 +0000
committertv <tv@krebsco.de>2026-11-24 05:42:04 +0000
commit2fe4955d641d2bda41e468ac1778def2572a4428 (patch)
tree63200781c05139ee96169aa5b8e5862733bc278d /krops.nix
parentd9a22706f74adc966198907d9df5986b551bbaa0 (diff)
krops.nix: take only numbers as ports
Diffstat (limited to 'krops.nix')
-rw-r--r--krops.nix10
1 files changed, 7 insertions, 3 deletions
diff --git a/krops.nix b/krops.nix
index dfa2121d..9997895b 100644
--- a/krops.nix
+++ b/krops.nix
@@ -166,10 +166,14 @@ rec {
q = lib.escapeShellArg;
nix = "nix --extra-experimental-features nix-command";
jq = "${pkgs.jq}/bin/jq";
+ # A port is digits, so it needs no quoting in ssh's options.
+ sshOptsOf = s: t:
+ assert lib.assertMsg (t.port == null || lib.match "[0-9]+" t.port != null)
+ "${name}: ${s}: port ${t.port} isn't a number";
+ lib.optionalString (t.port != null) "-p ${t.port}";
targetDest =
lib.optionalString (target'.user != null) "${target'.user}@" + target'.host;
- targetSSHOpts =
- lib.optionalString (target'.port != null) "-p ${target'.port}";
+ targetSSHOpts = sshOptsOf target target';
targetURL = "${spec.targetStore}://${targetDest}";
# The builders, as targets like populate's, [USER@]HOST[:PORT]/PATH:
# PATH is where a builder keeps the GC roots of the systems it builds,
@@ -184,7 +188,7 @@ rec {
"${name}: copyVia = \"deployer\" can't use ports for both ${s} and the target";
{
dest = lib.optionalString (t.user != null) "${t.user}@" + t.host;
- sshOpts = lib.optionalString (t.port != null) "-p ${t.port}";
+ sshOpts = sshOptsOf s t;
inherit (t) path;
}) spec.builders;
targetSource = lib.evalSource [ targetSources ];