From 2fe4955d641d2bda41e468ac1778def2572a4428 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 24 Nov 2026 05:36:24 +0000 Subject: krops.nix: take only numbers as ports --- krops.nix | 10 +++++++--- 1 file 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 ]; -- cgit v1.3.1