krebs: move retiolum-hosts to dedicated file

This commit is contained in:
tv 2019-01-21 10:54:01 +01:00
parent da79d23ebb
commit 799f132d58
2 changed files with 29 additions and 23 deletions

View File

@ -43,6 +43,7 @@ let
./Reaktor.nix ./Reaktor.nix
./realwallpaper.nix ./realwallpaper.nix
./retiolum-bootstrap.nix ./retiolum-bootstrap.nix
./retiolum-hosts.nix
./rtorrent.nix ./rtorrent.nix
./secret.nix ./secret.nix
./setuid.nix ./setuid.nix
@ -147,29 +148,6 @@ 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))))}
'';
};
services.openssh.hostKeys = services.openssh.hostKeys =
let inherit (config.krebs.build.host.ssh) privkey; in let inherit (config.krebs.build.host.ssh) privkey; in
mkIf (privkey != null) (mkForce [privkey]); mkIf (privkey != null) (mkForce [privkey]);

View File

@ -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))))
}
'';
};
}