summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-05-09 23:42:18 +0200
committertv <tv@krebsco.de>2017-05-09 23:42:18 +0200
commit66f9170f524a1a59ba7b69b2fc778c99ccbd41ff (patch)
tree5324c693af99e6798c918ace2bc1bffb0b8365e4
parent1b77fcae885722fb5d557e03f5e97d1d64df1d2b (diff)
retiolum-hosts: init
-rw-r--r--krebs/3modules/default.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix
index ea2979df4..daa963bc8 100644
--- a/krebs/3modules/default.nix
+++ b/krebs/3modules/default.nix
@@ -139,6 +139,29 @@ let
) cfg.hosts
));
+ # TODO dedup with networking.extraHosts
+ nixpkgs.config.packageOverrides = oldpkgs:
+ let
+ domains = attrNames (filterAttrs (_: eq "hosts") cfg.dns.providers);
+ check = hostname: any (domain: hasSuffix ".${domain}" hostname) domains;
+ in
+ {
+ retiolum-hosts = oldpkgs.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 cfg.hosts))))}
+ '';
+ };
+
# Implements environment.etc."zones/<zone-name>"
environment.etc = let
stripEmptyLines = s: (concatStringsSep "\n"