summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-08-16 11:28:27 +0200
committertv <tv@krebsco.de>2020-08-16 11:34:29 +0200
commitb0880d573677e0f32562a40d127910ec6a1d3ae2 (patch)
tree607a3fc8d2db98ac09952f0cc70e44a427a795e7
parentb63d24d58e1734b986d8e1fa5930e4ba51ddc4bc (diff)
krebs.dns: allow disabling search-domain
-rw-r--r--krebs/3modules/default.nix11
-rw-r--r--krebs/3modules/dns.nix2
-rw-r--r--krebs/3modules/hosts.nix6
3 files changed, 13 insertions, 6 deletions
diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix
index f3180722d..ccc3a44b9 100644
--- a/krebs/3modules/default.nix
+++ b/krebs/3modules/default.nix
@@ -152,9 +152,11 @@ let
let
longs = net.aliases;
shorts =
- map (removeSuffix ".${cfg.dns.search-domain}")
- (filter (hasSuffix ".${cfg.dns.search-domain}")
- longs);
+ optionals
+ (cfg.dns.search-domain != null)
+ (map (removeSuffix ".${cfg.dns.search-domain}")
+ (filter (hasSuffix ".${cfg.dns.search-domain}")
+ longs));
add-port = a:
if net.ssh.port != 22
then "[${a}]:${toString net.ssh.port}"
@@ -177,7 +179,8 @@ let
(concatMap (host: attrValues host.nets)
(mapAttrsToList
(_: 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} // {
aliases = [host.name];
addrs = [];
diff --git a/krebs/3modules/dns.nix b/krebs/3modules/dns.nix
index b7e2a2cbb..8acc4ccd8 100644
--- a/krebs/3modules/dns.nix
+++ b/krebs/3modules/dns.nix
@@ -6,7 +6,7 @@ with import <stockholm/lib>;
};
krebs.dns.search-domain = mkOption {
- type = types.hostname;
+ type = types.nullOr types.hostname;
};
};
}
diff --git a/krebs/3modules/hosts.nix b/krebs/3modules/hosts.nix
index 7fe01a769..159b54e34 100644
--- a/krebs/3modules/hosts.nix
+++ b/krebs/3modules/hosts.nix
@@ -24,7 +24,11 @@ in {
aliases = longs ++ shorts;
longs = filter check net.aliases;
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
map (addr: { ${addr} = aliases; }) net.addrs)
(attrValues host.nets))