From 6840ea1191dd7fc1ad02ae698875e044265d716b Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 25 Jul 2015 00:04:04 +0200 Subject: tv.identity -> krebs.build + extraHosts hack --- 3modules/krebs/default.nix | 72 +++++++++++++++++++++++++++++++++++++++++++ 3modules/tv/default.nix | 1 - 3modules/tv/identity.nix | 77 ---------------------------------------------- 3 files changed, 72 insertions(+), 78 deletions(-) delete mode 100644 3modules/tv/identity.nix (limited to '3modules') diff --git a/3modules/krebs/default.nix b/3modules/krebs/default.nix index 999e68da2..601ecf017 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,69 @@ 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] -> set providername [alias] + splitByProvider = foldl (acc: alias: insert (providerOf alias) alias acc) {}; + + # providerOf : alias -> providername + providerOf = alias: + tree-get (splitString "." alias) providers; + + # insert : k -> v -> set k [v] -> set k [v] + insert = name: value: set: + set // { ${name} = set.${name} or [] ++ [value]; }; + + # tree k v = set k (either v (tree k v)) + + # tree-get : [k] -> tree k v -> v + tree-get = path: x: + let + y = x.${last path}; + in + if typeOf y != "set" + then y + else tree-get (init path) y; + 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 = { diff --git a/3modules/tv/default.nix b/3modules/tv/default.nix index e267d0b9f..bb10d8261 100644 --- a/3modules/tv/default.nix +++ b/3modules/tv/default.nix @@ -4,7 +4,6 @@ _: imports = [ ./consul.nix ./ejabberd.nix - ./identity.nix ./iptables.nix ]; } diff --git a/3modules/tv/identity.nix b/3modules/tv/identity.nix deleted file mode 100644 index 9de432203..000000000 --- a/3modules/tv/identity.nix +++ /dev/null @@ -1,77 +0,0 @@ -{ config, lib, pkgs, ... }: - -with import ../../4lib/tv { inherit lib pkgs; }; -let - cfg = config.tv.identity; - - out = { - options.tv.identity = api; - config = mkIf cfg.enable imp; - }; - - api = { - enable = mkEnableOption "tv.identity"; - - self = mkOption { - type = types.host; - }; - - #others = mkOption { - # type = types.host; - # default = filterAttrs (name: _host: name != cfg.self.name) cfg.hosts; - #}; - - search = mkOption { - type = types.hostname; - }; - }; - - imp = { - networking.extraHosts = - 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}") longs; - in - map (addr: "${addr} ${aliases}") net.addrs - ) host.nets - ) config.krebs.hosts - )); - }; - - # 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] -> set providername [alias] - splitByProvider = foldl (acc: alias: insert (providerOf alias) alias acc) {}; - - # providerOf : alias -> providername - providerOf = alias: - tree-get (splitString "." alias) providers; - - # insert : k -> v -> set k [v] -> set k [v] - insert = name: value: set: - set // { ${name} = set.${name} or [] ++ [value]; }; - - # tree k v = set k (either v (tree k v)) - - # tree-get : [k] -> tree k v -> v - tree-get = path: x: - let - y = x.${last path}; - in - if typeOf y != "set" - then y - else tree-get (init path) y; -in -out -- cgit v1.2.3 From 14250e66a7b15a6ece190ba55f672fb103eadaa3 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 25 Jul 2015 00:44:24 +0200 Subject: krebs.users += mv --- 3modules/krebs/default.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to '3modules') diff --git a/3modules/krebs/default.nix b/3modules/krebs/default.nix index 601ecf017..23b3ab7ec 100644 --- a/3modules/krebs/default.nix +++ b/3modules/krebs/default.nix @@ -308,6 +308,9 @@ let }; }; users = addNames { + mv = { + pubkey = readFile ../../Zpubkeys/mv_vod.ssh.pub; + }; tv = { pubkey = readFile ../../Zpubkeys/tv_wu.ssh.pub; }; -- cgit v1.2.3 From d03dba41d6543adc2c73a7818cd32ca79046c64b Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 25 Jul 2015 01:06:13 +0200 Subject: krebs.users.[mt]v: set mail --- 3modules/krebs/default.nix | 2 ++ 1 file changed, 2 insertions(+) (limited to '3modules') diff --git a/3modules/krebs/default.nix b/3modules/krebs/default.nix index 23b3ab7ec..43e7e4c59 100644 --- a/3modules/krebs/default.nix +++ b/3modules/krebs/default.nix @@ -309,9 +309,11 @@ 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; }; }; -- cgit v1.2.3 From 1eb292f0c9eeb7d0fad6738bc4f06e646cae289e Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 25 Jul 2015 01:29:37 +0200 Subject: krebs.git.repos.*.hooks: default = {} --- 3modules/krebs/git.nix | 1 + 1 file changed, 1 insertion(+) (limited to '3modules') diff --git a/3modules/krebs/git.nix b/3modules/krebs/git.nix index 499d33095..604645189 100644 --- a/3modules/krebs/git.nix +++ b/3modules/krebs/git.nix @@ -72,6 +72,7 @@ let }; hooks = mkOption { type = types.attrsOf types.str; + default = {}; description = '' Repository-specific hooks. ''; -- cgit v1.2.3 From 0a5548c379a373157448c3b3798073c6d426033b Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 25 Jul 2015 02:14:44 +0200 Subject: {3 -> 4} krebs {listset,tree} --- 3modules/krebs/default.nix | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to '3modules') diff --git a/3modules/krebs/default.nix b/3modules/krebs/default.nix index 43e7e4c59..33c108811 100644 --- a/3modules/krebs/default.nix +++ b/3modules/krebs/default.nix @@ -68,27 +68,12 @@ let de.krebsco = "ovh"; }; - # splitByProvider : [alias] -> set providername [alias] - splitByProvider = foldl (acc: alias: insert (providerOf alias) alias acc) {}; + # 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; - - # insert : k -> v -> set k [v] -> set k [v] - insert = name: value: set: - set // { ${name} = set.${name} or [] ++ [value]; }; - - # tree k v = set k (either v (tree k v)) - - # tree-get : [k] -> tree k v -> v - tree-get = path: x: - let - y = x.${last path}; - in - if typeOf y != "set" - then y - else tree-get (init path) y; in concatStringsSep "\n" (flatten ( # TODO deepMap ["hosts" "nets"] (hostname: host: netname: net: -- cgit v1.2.3