summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2018-07-12 14:14:27 +0200
committertv <tv@krebsco.de>2018-07-12 14:14:27 +0200
commite8505f71ff4741156fc3ce05542dd3aa70798214 (patch)
tree1cf48da78e771a839765a566e7bbf38e32d9951f /lib
parent9677846bf5770f17dcc87a3fa9855343dc9248ca (diff)
lib: add isLocalTarget
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 7197fe9..ae1cef9 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -34,6 +34,12 @@ let {
if lib.length y != 1 then throw "malformed /etc/hostname" else
lib.elemAt y 0;
+ isLocalTarget = let
+ origin = lib.mkTarget "";
+ in target:
+ target.user == origin.user &&
+ lib.elem target.host [origin.host "localhost"];
+
mkTarget = s: let
default = defVal: val: if val != null then val else defVal;
parse = lib.match "(([^@]+)@)?(([^:/]+))?(:([^/]+))?(/.*)?" s;