aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-04-19 01:06:20 +0200
committerGitHub <noreply@github.com>2020-04-19 01:06:20 +0200
commit55aa2c77ce8183f3d2b24f54efa33ab6a42e1e02 (patch)
tree4b22fdcbaf03db8fd2ed6c9d2b6844b9cdf6d02d
parent9c16ab1ce11eb2c16af97e1b293961178a9f1b7b (diff)
parent8a8b2cf86197d4550c3bf2bee5f57ac1036c5ceb (diff)
Merge pull request #19 from erikarvstedt/improve-target-optsv1.21.0
Improve deploy target options
-rw-r--r--lib/default.nix20
-rw-r--r--pkgs/krops/default.nix1
-rw-r--r--pkgs/populate/default.nix1
3 files changed, 15 insertions, 7 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 9fdde0b..5829250 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -43,16 +43,22 @@ let {
lib.elem target.host [origin.host "localhost"];
mkTarget = s: let
- default = defVal: val: if val != null then val else defVal;
parse = lib.match "(([^@]*)@)?(([^:/]+))?(:([^/]+))?(/.*)?" s;
elemAt' = xs: i: if lib.length xs > i then lib.elemAt xs i else null;
- in if lib.isString s then {
- user = default (lib.getEnv "LOGNAME") (elemAt' parse 1);
- host = default (lib.maybeEnv "HOSTNAME" lib.getHostName) (elemAt' parse 3);
- port = default "22" /* "ssh"? */ (elemAt' parse 5);
- path = default "/var/src" /* no default? */ (elemAt' parse 6);
+ filterNull = lib.filterAttrs (n: v: v != null);
+ in {
+ user = lib.getEnv "LOGNAME";
+ host = lib.maybeEnv "HOSTNAME" lib.getHostName;
+ port = "22";
+ path = "/var/src";
sudo = false;
- } else s;
+ extraOptions = [];
+ } // (if lib.isString s then filterNull {
+ user = elemAt' parse 1;
+ host = elemAt' parse 3;
+ port = elemAt' parse 5;
+ path = elemAt' parse 6;
+ } else s);
shell = let
isSafeChar = lib.testString "[-+./0-9:=A-Z_a-z]";
diff --git a/pkgs/krops/default.nix b/pkgs/krops/default.nix
index 07c7395..4760287 100644
--- a/pkgs/krops/default.nix
+++ b/pkgs/krops/default.nix
@@ -23,6 +23,7 @@ in
(lib.optionals (target.user != "") ["-l" target.user])
"-p" target.port
"-t"
+ target.extraOptions
target.host
(if target.sudo then "sudo ${command}" else command)])}
'';
diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix
index 78bf3c8..36a97b3 100644
--- a/pkgs/populate/default.nix
+++ b/pkgs/populate/default.nix
@@ -194,6 +194,7 @@ let
"-o" "ControlPersist=no"
"-p" target.port
"-T"
+ target.extraOptions
]);
in