retiolum-hosts: init

This commit is contained in:
tv 2017-05-09 23:42:18 +02:00
parent 1b77fcae88
commit 66f9170f52

View File

@ -139,6 +139,29 @@ let
) cfg.hosts ) 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>" # Implements environment.etc."zones/<zone-name>"
environment.etc = let environment.etc = let
stripEmptyLines = s: (concatStringsSep "\n" stripEmptyLines = s: (concatStringsSep "\n"