summaryrefslogtreecommitdiffstats
path: root/krebs/4lib/types.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-04-07 20:29:07 +0200
committertv <tv@krebsco.de>2016-04-07 20:29:07 +0200
commit033bf438bd2ae39d6a465c475500a24514cc2739 (patch)
treec9ae48a76d41cac7d84b4516fb6284f4d848382a /krebs/4lib/types.nix
parentbcb395fa76e35e82b68b16a9d4958087da1a0803 (diff)
addr4: str -> mkOptionType
Diffstat (limited to 'krebs/4lib/types.nix')
-rw-r--r--krebs/4lib/types.nix14
1 files changed, 10 insertions, 4 deletions
diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix
index 32d1daf9d..7255dc3e1 100644
--- a/krebs/4lib/types.nix
+++ b/krebs/4lib/types.nix
@@ -186,10 +186,16 @@ types // rec {
};
});
- # TODO
- addr = str;
- addr4 = str;
- addr6 = str;
+ addr = either addr4 addr6;
+ addr4 = mkOptionType {
+ name = "IPv4 address";
+ check = let
+ IPv4address = let d = "([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"; in
+ concatMapStringsSep "." (const d) (range 1 4);
+ in x: match IPv4address != null;
+ merge = mergeOneOption;
+ };
+ addr6 = str; # TODO
pgp-pubkey = str;