krebs: move dns stuff to dedicated file

This commit is contained in:
tv 2019-01-21 10:32:15 +01:00
parent 9082adf687
commit da79d23ebb
4 changed files with 20 additions and 20 deletions

View file

@ -18,6 +18,7 @@ let
./charybdis.nix ./charybdis.nix
./ci.nix ./ci.nix
./current.nix ./current.nix
./dns.nix
./exim.nix ./exim.nix
./exim-retiolum.nix ./exim-retiolum.nix
./exim-smarthost.nix ./exim-smarthost.nix
@ -59,12 +60,6 @@ let
api = { api = {
enable = mkEnableOption "krebs"; enable = mkEnableOption "krebs";
dns = {
providers = mkOption {
type = with types; attrsOf str;
};
};
hosts = mkOption { hosts = mkOption {
type = with types; attrsOf host; type = with types; attrsOf host;
default = {}; default = {};
@ -74,13 +69,6 @@ let
type = with types; attrsOf user; type = with types; attrsOf user;
}; };
# XXX is there a better place to define search-domain?
# TODO search-domains :: listOf hostname
search-domain = mkOption {
type = types.hostname;
default = "r";
};
sitemap = mkOption { sitemap = mkOption {
default = {}; default = {};
type = types.attrsOf types.sitemap.entry; type = types.attrsOf types.sitemap.entry;
@ -126,6 +114,8 @@ let
w = "hosts"; w = "hosts";
}; };
krebs.dns.search-domain = mkDefault "r";
krebs.users = { krebs.users = {
krebs = { krebs = {
home = "/krebs"; home = "/krebs";
@ -147,7 +137,7 @@ let
let let
aliases = longs ++ shorts; aliases = longs ++ shorts;
longs = filter check net.aliases; longs = filter check net.aliases;
shorts = let s = ".${cfg.search-domain}"; in shorts = let s = ".${cfg.dns.search-domain}"; in
map (removeSuffix s) (filter (hasSuffix s) longs); map (removeSuffix s) (filter (hasSuffix s) longs);
in in
optionals optionals
@ -203,8 +193,8 @@ let
let let
longs = net.aliases; longs = net.aliases;
shorts = shorts =
map (removeSuffix ".${cfg.search-domain}") map (removeSuffix ".${cfg.dns.search-domain}")
(filter (hasSuffix ".${cfg.search-domain}") (filter (hasSuffix ".${cfg.dns.search-domain}")
longs); longs);
add-port = a: add-port = a:
if net.ssh.port != 22 if net.ssh.port != 22
@ -228,8 +218,8 @@ let
(concatMap (host: attrValues host.nets) (concatMap (host: attrValues host.nets)
(mapAttrsToList (mapAttrsToList
(_: host: recursiveUpdate host (_: host: recursiveUpdate host
(optionalAttrs (hasAttr config.krebs.search-domain host.nets) { (optionalAttrs (hasAttr cfg.dns.search-domain host.nets) {
nets."" = host.nets.${config.krebs.search-domain} // { nets."" = host.nets.${cfg.dns.search-domain} // {
aliases = [host.name]; aliases = [host.name];
addrs = []; addrs = [];
}; };

12
krebs/3modules/dns.nix Normal file
View file

@ -0,0 +1,12 @@
with import <stockholm/lib>;
{
options = {
krebs.dns.providers = mkOption {
type = types.attrsOf types.str;
};
krebs.dns.search-domain = mkOption {
type = types.hostname;
};
};
}

View file

@ -72,7 +72,6 @@ with import <stockholm/lib>;
krebs = { krebs = {
enable = true; enable = true;
search-domain = "r";
build.user = config.krebs.users.lass; build.user = config.krebs.users.lass;
}; };

View file

@ -36,7 +36,6 @@ with import <stockholm/lib>;
enable = true; enable = true;
dns.providers.lan = "hosts"; dns.providers.lan = "hosts";
search-domain = "r";
build.user = config.krebs.users.makefu; build.user = config.krebs.users.makefu;
}; };