From 46e818ebbc5446b4215ad9524089d9b2dc91cbd3 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 8 Apr 2016 03:53:34 +0200 Subject: retiolum: don't hardcode routing prefixes --- krebs/4lib/types.nix | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'krebs/4lib') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 7255dc3e1..24b4e14b1 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -63,28 +63,56 @@ types // rec { net = submodule ({ config, ... }: { options = { + name = mkOption { + type = label; + default = config._module.args.name; + }; via = mkOption { type = nullOr net; default = null; }; addrs = mkOption { type = listOf addr; - default = config.addrs4 ++ config.addrs6; - # TODO only default addrs make sense - }; - addrs4 = mkOption { - type = listOf addr4; - default = []; - }; - addrs6 = mkOption { - type = listOf addr6; - default = []; + default = + optional (config.ip4 != null) config.ip4.addr ++ + optional (config.ip6 != null) config.ip6.addr; + readOnly = true; }; aliases = mkOption { # TODO nonEmptyListOf hostname type = listOf hostname; default = []; }; + ip4 = mkOption { + type = nullOr (submodule { + options = { + addr = mkOption { + type = addr4; + }; + prefix = mkOption ({ + type = str; # TODO routing prefix (CIDR) + } // optionalAttrs (config.name == "retiolum") { + default = "10.243.0.0/16"; + }); + }; + }); + default = null; + }; + ip6 = mkOption { + type = nullOr (submodule { + options = { + addr = mkOption { + type = addr6; + }; + prefix = mkOption ({ + type = str; # TODO routing prefix (CIDR) + } // optionalAttrs (config.name == "retiolum") { + default = "42::/16"; + }); + }; + }); + default = null; + }; ssh = mkOption { type = submodule { options = { -- cgit v1.2.3