diff options
author | nin <nineinchnade@gmail.com> | 2017-10-17 19:54:15 +0200 |
---|---|---|
committer | nin <nineinchnade@gmail.com> | 2017-10-17 19:54:15 +0200 |
commit | 9afe5210f2a44cacac4f3527b6c8b561d9e4296b (patch) | |
tree | a83c412966783b123cd3152fe34a6f7cddcb55d6 /lib/types.nix | |
parent | f4bf9110727f2c7113c80aaa88427b81605016ae (diff) | |
parent | 4667bb8e4111abde822ae57993a29929c5cc9aad (diff) |
Merge remote-tracking branch 'temp/master'
Diffstat (limited to 'lib/types.nix')
-rw-r--r-- | lib/types.nix | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/types.nix b/lib/types.nix index 70570a6b3..08dc0974e 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -92,7 +92,7 @@ rec { default = null; }; addrs = mkOption { - type = listOf addr; + type = listOf cidr; default = optional (config.ip4 != null) config.ip4.addr ++ optional (config.ip6 != null) config.ip6.addr; @@ -109,7 +109,7 @@ rec { type = addr4; }; prefix = mkOption ({ - type = str; # TODO routing prefix (CIDR) + type = cidr4; } // optionalAttrs (config.name == "retiolum") { default = "10.243.0.0/16"; }); @@ -125,7 +125,7 @@ rec { apply = lib.normalize-ip6-addr; }; prefix = mkOption ({ - type = str; # TODO routing prefix (CIDR) + type = cidr6; } // optionalAttrs (config.name == "retiolum") { default = "42::/16"; }); @@ -364,6 +364,26 @@ rec { merge = mergeOneOption; }; + cidr = either cidr4 cidr6; + cidr4 = mkOptionType { + name = "CIDRv4 address"; + check = let + CIDRv4address = 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) + "(/([1-2]?[0-9]|3[0-2]))?"; + in + test CIDRv4address; + merge = mergeOneOption; + }; + cidr6 = mkOptionType { + name = "CIDRv6 address"; + check = let + # TODO check IPv6 address harder + CIDRv6address = "[0-9a-f.:]+(/([0-9][0-9]?|1[0-2][0-8]))?"; + in + test CIDRv6address; + merge = mergeOneOption; + }; + binary-cache-pubkey = str; pgp-pubkey = str; |