summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/retiolum-hosts.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-01-21 10:54:01 +0100
committertv <tv@krebsco.de>2019-01-21 10:54:01 +0100
commit799f132d588f2a5f6c6dabc43e862c90d9efa4b7 (patch)
tree720e9f9eee54dcb5708834e204d4cbd08d13343a /krebs/3modules/retiolum-hosts.nix
parentda79d23ebbc0c3fb7c579b366f29fb3744948706 (diff)
krebs: move retiolum-hosts to dedicated file
Diffstat (limited to 'krebs/3modules/retiolum-hosts.nix')
-rw-r--r--krebs/3modules/retiolum-hosts.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/krebs/3modules/retiolum-hosts.nix b/krebs/3modules/retiolum-hosts.nix
new file mode 100644
index 000000000..2821d62d1
--- /dev/null
+++ b/krebs/3modules/retiolum-hosts.nix
@@ -0,0 +1,28 @@
+with import <stockholm/lib>;
+{ config, ... }: let
+ # TODO dedup functions with networking.extraHosts
+ check = hostname: any (domain: hasSuffix ".${domain}" hostname) domains;
+ domains = attrNames (filterAttrs (_: eq "hosts") config.krebs.dns.providers);
+in {
+ nixpkgs.config.packageOverrides = super: {
+ retiolum-hosts =
+ super.writeText "retiolum-hosts" ''
+ ${
+ concatStringsSep
+ "\n"
+ (flatten
+ (map
+ (host: let
+ net = host.nets.retiolum;
+ aliases = longs;
+ longs = filter check net.aliases;
+ in
+ optionals
+ (aliases != [])
+ (map (addr: "${addr} ${toString aliases}") net.addrs))
+ (filter (host: hasAttr "retiolum" host.nets)
+ (attrValues config.krebs.hosts))))
+ }
+ '';
+ };
+}