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/types.nix') 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 From 4e99bb9d12405cf1910af3205d8668604e516f50 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 8 Apr 2016 04:38:10 +0200 Subject: krebs types.addr4: check type harder --- krebs/4lib/types.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 24b4e14b1..6396927dd 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -220,7 +220,7 @@ types // rec { 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; + in x: match IPv4address x != null; merge = mergeOneOption; }; addr6 = str; # TODO -- cgit v1.2.3 From e74f4ddf8182067ca4f44d8d4ed91a8c5fc65147 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 8 Apr 2016 04:41:30 +0200 Subject: krebs types.addr6: str -> IPv6 address* --- krebs/4lib/types.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 6396927dd..f46491801 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -223,7 +223,14 @@ types // rec { in x: match IPv4address x != null; merge = mergeOneOption; }; - addr6 = str; # TODO + addr6 = mkOptionType { + name = "IPv6 address"; + check = let + # TODO check IPv6 address harder + IPv6address = "[0-9a-f.:]+"; + in x: match IPv6address x != null; + merge = mergeOneOption; + }; pgp-pubkey = str; -- cgit v1.2.3 From affb69250d13f64d2be14327c1b47d23cadcb987 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 17 Apr 2016 04:13:32 +0200 Subject: krebs.backup network-ssh-port: fail if cannot find port --- krebs/4lib/types.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index f46491801..405a91e45 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -117,8 +117,8 @@ types // rec { type = submodule { options = { port = mkOption { - type = nullOr int; - default = null; + type = int; + default = 22; }; }; }; -- cgit v1.2.3 From 87dabec64d9dbe35f1fcc35b7b4c8ab00a02cf84 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 27 Apr 2016 01:33:39 +0200 Subject: krebs types.group: init --- krebs/4lib/types.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 405a91e45..56d1d55c3 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -213,6 +213,18 @@ types // rec { }; }; }); + group = submodule ({ config, ... }: { + options = { + name = mkOption { + type = username; + default = config._module.args.name; + }; + gid = mkOption { + type = int; + default = genid config.name; + }; + }; + }); addr = either addr4 addr6; addr4 = mkOptionType { -- cgit v1.2.3 [cgit] Unable to lock slot /tmp/cgit/38300000.lock: No such file or directory (2)