diff options
author | makefu <github@syntax-fehler.de> | 2015-07-26 18:11:09 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2015-07-26 18:11:09 +0200 |
commit | c355a1d86250aca3f5757082ddd392ef867ca4ee (patch) | |
tree | a9a596081878d3117e625b9ce164c82339e35812 /3modules/krebs/default.nix | |
parent | f338d3d4d15ff29b3048b4f89716a8aa1a19f21b (diff) | |
parent | cea33984057136ea0deac369650e490f420b5445 (diff) |
Merge remote-tracking branch 'cd/master'
Diffstat (limited to '3modules/krebs/default.nix')
-rw-r--r-- | 3modules/krebs/default.nix | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/3modules/krebs/default.nix b/3modules/krebs/default.nix index 999e68da2..33c108811 100644 --- a/3modules/krebs/default.nix +++ b/3modules/krebs/default.nix @@ -19,6 +19,21 @@ let api = { enable = mkEnableOption "krebs"; + build = mkOption { + type = types.submodule { + options = { + host = mkOption { + type = types.host; + }; + user = mkOption { + type = types.user; + }; + }; + }; + # Define defaul value, so unset values of the submodule get reported. + default = {}; + }; + hosts = mkOption { type = with types; attrsOf host; }; @@ -26,12 +41,54 @@ let users = mkOption { type = with types; attrsOf user; }; + + # XXX is there a better place to define search-domain? + # TODO search-domains :: listOf hostname + search-domain = mkOption { + type = types.hostname; + default = ""; + example = "retiolum"; + }; }; imp = mkMerge [ { krebs = lass-imp; } { krebs = makefu-imp; } { krebs = tv-imp; } + { + # XXX This overlaps with krebs.retiolum + networking.extraHosts = + let + # TODO move domain name providers to a dedicated module + # providers : tree label providername + providers = { + internet = "hosts"; + retiolum = "hosts"; + de.viljetic = "regfish"; + de.krebsco = "ovh"; + }; + + # splitByProvider : [alias] -> listset providername alias + splitByProvider = foldl (acc: alias: listset-insert (providerOf alias) alias acc) {}; + + # providerOf : alias -> providername + providerOf = alias: + tree-get (splitString "." alias) providers; + in + concatStringsSep "\n" (flatten ( + # TODO deepMap ["hosts" "nets"] (hostname: host: netname: net: + mapAttrsToList (hostname: host: + mapAttrsToList (netname: net: + let + aliases = toString (unique (longs ++ shorts)); + longs = (splitByProvider net.aliases).hosts; + shorts = map (removeSuffix ".${cfg.search-domain}") longs; + in + map (addr: "${addr} ${aliases}") net.addrs + ) host.nets + ) config.krebs.hosts + )); + } ]; lass-imp = { @@ -236,7 +293,12 @@ let }; }; users = addNames { + mv = { + mail = "mv@cd.retiolum"; + pubkey = readFile ../../Zpubkeys/mv_vod.ssh.pub; + }; tv = { + mail = "tv@wu.retiolum"; pubkey = readFile ../../Zpubkeys/tv_wu.ssh.pub; }; }; |