krebs.dns: allow disabling search-domain

This commit is contained in:
tv 2020-08-16 11:28:27 +02:00
parent b63d24d58e
commit b0880d5736
3 changed files with 13 additions and 6 deletions

View File

@ -152,9 +152,11 @@ let
let let
longs = net.aliases; longs = net.aliases;
shorts = shorts =
map (removeSuffix ".${cfg.dns.search-domain}") optionals
(filter (hasSuffix ".${cfg.dns.search-domain}") (cfg.dns.search-domain != null)
longs); (map (removeSuffix ".${cfg.dns.search-domain}")
(filter (hasSuffix ".${cfg.dns.search-domain}")
longs));
add-port = a: add-port = a:
if net.ssh.port != 22 if net.ssh.port != 22
then "[${a}]:${toString net.ssh.port}" then "[${a}]:${toString net.ssh.port}"
@ -177,7 +179,8 @@ let
(concatMap (host: attrValues host.nets) (concatMap (host: attrValues host.nets)
(mapAttrsToList (mapAttrsToList
(_: host: recursiveUpdate host (_: host: recursiveUpdate host
(optionalAttrs (hasAttr cfg.dns.search-domain host.nets) { (optionalAttrs (cfg.dns.search-domain != null &&
hasAttr cfg.dns.search-domain host.nets) {
nets."" = host.nets.${cfg.dns.search-domain} // { nets."" = host.nets.${cfg.dns.search-domain} // {
aliases = [host.name]; aliases = [host.name];
addrs = []; addrs = [];

View File

@ -6,7 +6,7 @@ with import <stockholm/lib>;
}; };
krebs.dns.search-domain = mkOption { krebs.dns.search-domain = mkOption {
type = types.hostname; type = types.nullOr types.hostname;
}; };
}; };
} }

View File

@ -24,7 +24,11 @@ in {
aliases = longs ++ shorts; aliases = longs ++ shorts;
longs = filter check net.aliases; longs = filter check net.aliases;
shorts = let s = ".${config.krebs.dns.search-domain}"; in shorts = let s = ".${config.krebs.dns.search-domain}"; in
map (removeSuffix s) (filter (hasSuffix s) longs); optionals
(config.krebs.dns.search-domain != null)
(map (removeSuffix s)
(filter (hasSuffix s)
longs));
in in
map (addr: { ${addr} = aliases; }) net.addrs) map (addr: { ${addr} = aliases; }) net.addrs)
(attrValues host.nets)) (attrValues host.nets))