summaryrefslogtreecommitdiffstats
path: root/krebs/4lib
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2016-05-24 22:12:38 +0200
committermakefu <github@syntax-fehler.de>2016-05-24 22:12:38 +0200
commit9cba0ffefa95079168f3419cf11eb98400a468db (patch)
treef483f11d62ced67b06e017a65417135b9ba8a2ce /krebs/4lib
parent4de1c87ff62dadc4cbe812a48d10241d79aca183 (diff)
parentc44e649455f3c162b66fb9d2d678a7a0eeff598b (diff)
merge cd/master
Diffstat (limited to 'krebs/4lib')
-rw-r--r--krebs/4lib/types.nix75
1 files changed, 61 insertions, 14 deletions
diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix
index 7255dc3e1..56d1d55c3 100644
--- a/krebs/4lib/types.nix
+++ b/krebs/4lib/types.nix
@@ -63,34 +63,62 @@ 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 = {
port = mkOption {
- type = nullOr int;
- default = null;
+ type = int;
+ default = 22;
};
};
};
@@ -185,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 {
@@ -192,10 +232,17 @@ 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 = mkOptionType {
+ name = "IPv6 address";
+ check = let
+ # TODO check IPv6 address harder
+ IPv6address = "[0-9a-f.:]+";
+ in x: match IPv6address x != null;
merge = mergeOneOption;
};
- addr6 = str; # TODO
pgp-pubkey = str;