summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-10-26 18:43:33 +0200
committertv <tv@krebsco.de>2017-10-26 18:43:33 +0200
commitd5fd5107e6cd8e4d1cd0e63420d35a9df5279e7f (patch)
tree05731b063ed6243632b6c3a61a329618da6a6951 /lib
parent1993cbc42114c759a47fed8de1e73980d3df57d9 (diff)
parent458bd5f6bda5b5718959613ceb989862a530ed7b (diff)
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'lib')
-rw-r--r--lib/types.nix26
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;