diff options
author | lassulus <lassulus@lassul.us> | 2019-01-21 16:24:43 +0100 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2019-01-21 16:24:43 +0100 |
commit | 144e2c5571129ac01b65d44db224c233ee1ac851 (patch) | |
tree | ec8ca31f0ff61f20494a7c77c967481994e98d89 /krebs/3modules/hosts.nix | |
parent | bc61d4df9068fa3d63690891b3aaa8a982ceb633 (diff) | |
parent | fabef3638584e88be50b10ec1cf3649b98752eac (diff) |
Merge remote-tracking branch 'ni/master'
Diffstat (limited to 'krebs/3modules/hosts.nix')
-rw-r--r-- | krebs/3modules/hosts.nix | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/krebs/3modules/hosts.nix b/krebs/3modules/hosts.nix new file mode 100644 index 000000000..0985bb539 --- /dev/null +++ b/krebs/3modules/hosts.nix @@ -0,0 +1,35 @@ +with import <stockholm/lib>; +{ config, ... }: let + # TODO dedup functions with ./retiolum-hosts.nix + check = hostname: any (domain: hasSuffix ".${domain}" hostname) domains; + domains = attrNames (filterAttrs (_: eq "hosts") config.krebs.dns.providers); +in { + + options = { + krebs.hosts = mkOption { + default = {}; + type = types.attrsOf types.host; + }; + }; + + config = { + networking.hosts = + filterAttrs + (_name: value: value != []) + (zipAttrsWith + (_: concatLists) + (concatMap + (host: + concatMap + (net: let + aliases = longs ++ shorts; + longs = filter check net.aliases; + shorts = let s = ".${config.krebs.dns.search-domain}"; in + map (removeSuffix s) (filter (hasSuffix s) longs); + in + map (addr: { ${addr} = aliases; }) net.addrs) + (attrValues host.nets)) + (attrValues config.krebs.hosts))); + }; + +} |