From b0880d573677e0f32562a40d127910ec6a1d3ae2 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 16 Aug 2020 11:28:27 +0200 Subject: [PATCH 1/3] krebs.dns: allow disabling search-domain --- krebs/3modules/default.nix | 11 +++++++---- krebs/3modules/dns.nix | 2 +- krebs/3modules/hosts.nix | 6 +++++- 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 ; }; 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)) From c61d99ccc653c9bee950c9e2d8a3f5bf6f4d8d1c Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 19 Aug 2020 02:26:27 +0200 Subject: [PATCH 2/3] tv: privatize gg23 --- krebs/3modules/default.nix | 1 - krebs/3modules/tv/default.nix | 37 ------------------- tv/2configs/default.nix | 1 + tv/2configs/nets/gg23.nix | 69 +++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 38 deletions(-) create mode 100644 tv/2configs/nets/gg23.nix diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index ccc3a44b9..9e4146ff2 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -108,7 +108,6 @@ let { krebs.dns.providers = { "krebsco.de" = "zones"; - gg23 = "hosts"; shack = "hosts"; i = "hosts"; r = "hosts"; diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix index a20801b12..c2bf406f1 100644 --- a/krebs/3modules/tv/default.nix +++ b/krebs/3modules/tv/default.nix @@ -131,11 +131,6 @@ in { ci = true; cores = 2; nets = { - gg23 = { - ip4.addr = "10.23.1.110"; - aliases = ["nomic.gg23"]; - ssh.port = 11423; - }; retiolum = { ip4.addr = "10.243.0.110"; aliases = [ @@ -158,27 +153,10 @@ in { ssh.privkey.path = ; ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMIHmwXHV7E9UGuk4voVCADjlLkyygqNw054jvrsPn5t root@nomic"; }; - ok = { - external = true; - nets = { - gg23 = { - ip4.addr = "10.23.1.1"; - aliases = ["ok.gg23"]; - }; - }; - }; wu = { ci = true; cores = 4; nets = { - gg23 = { - ip4.addr = "10.23.1.37"; - aliases = [ - "wu.gg23" - "cache.wu.gg23" - ]; - ssh.port = 11423; - }; retiolum = { ip4.addr = "10.243.13.37"; aliases = [ @@ -237,14 +215,6 @@ in { ci = true; cores = 4; nets = { - gg23 = { - ip4.addr = "10.23.1.38"; - aliases = [ - "xu.gg23" - "cache.xu.gg23" - ]; - ssh.port = 11423; - }; retiolum = { ip4.addr = "10.243.13.38"; aliases = [ @@ -272,13 +242,6 @@ in { ci = true; cores = 4; nets = { - gg23 = { - ip4.addr = "10.23.1.39"; - aliases = [ - "zu.gg23" - ]; - ssh.port = 11423; - }; retiolum = { ip4.addr = "10.243.13.40"; aliases = [ diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 4d27b0eac..01f83482e 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -16,6 +16,7 @@ with import ; ./backup.nix ./bash ./htop.nix + ./nets/gg23.nix ./nginx ./pki ./ssh.nix diff --git a/tv/2configs/nets/gg23.nix b/tv/2configs/nets/gg23.nix new file mode 100644 index 000000000..fc5d239d5 --- /dev/null +++ b/tv/2configs/nets/gg23.nix @@ -0,0 +1,69 @@ +{ + krebs = { + dns.providers.gg23 = "hosts"; + hosts = { + nomic = { + nets.gg23 = { + ip4 = { + addr = "10.23.1.110"; + prefix = "10.23.1.0/24"; + }; + aliases = [ + "nomic.gg23" + ]; + ssh.port = 11423; + }; + }; + ok = { + external = true; + nets.gg23 = { + ip4 = { + addr = "10.23.1.1"; + prefix = "10.23.1.0/24"; + }; + aliases = [ + "ok.gg23" + ]; + }; + }; + wu = { + nets.gg23 = { + ip4 = { + addr = "10.23.1.37"; + prefix = "10.23.1.0/24"; + }; + aliases = [ + "wu.gg23" + "cache.wu.gg23" + ]; + ssh.port = 11423; + }; + }; + xu = { + nets.gg23 = { + ip4 = { + addr = "10.23.1.38"; + prefix = "10.23.1.0/24"; + }; + aliases = [ + "xu.gg23" + "cache.xu.gg23" + ]; + ssh.port = 11423; + }; + }; + zu = { + nets.gg23 = { + ip4 = { + addr = "10.23.1.39"; + prefix = "10.23.1.0/24"; + }; + aliases = [ + "zu.gg23" + ]; + ssh.port = 11423; + }; + }; + }; + }; +} From 358633f9737c8327d6028ebfadf72cbb51df70fb Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 19 Aug 2020 02:30:51 +0200 Subject: [PATCH 3/3] tv nets: gg23 -> hkw --- tv/2configs/binary-cache/default.nix | 2 +- tv/2configs/default.nix | 2 +- tv/2configs/nets/{gg23.nix => hkw.nix} | 26 +++++++++++++------------- tv/2configs/nginx/public_html.nix | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) rename tv/2configs/nets/{gg23.nix => hkw.nix} (76%) diff --git a/tv/2configs/binary-cache/default.nix b/tv/2configs/binary-cache/default.nix index 866434cb5..f6eaba36f 100644 --- a/tv/2configs/binary-cache/default.nix +++ b/tv/2configs/binary-cache/default.nix @@ -27,7 +27,7 @@ enable = true; virtualHosts.nix-serve = { serverAliases = [ - "cache.${config.krebs.build.host.name}.gg23" + "cache.${config.krebs.build.host.name}.hkw" ]; locations."/".extraConfig = '' proxy_pass http://localhost:${toString config.services.nix-serve.port}; diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 01f83482e..9db35184a 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -16,7 +16,7 @@ with import ; ./backup.nix ./bash ./htop.nix - ./nets/gg23.nix + ./nets/hkw.nix ./nginx ./pki ./ssh.nix diff --git a/tv/2configs/nets/gg23.nix b/tv/2configs/nets/hkw.nix similarity index 76% rename from tv/2configs/nets/gg23.nix rename to tv/2configs/nets/hkw.nix index fc5d239d5..725e63b13 100644 --- a/tv/2configs/nets/gg23.nix +++ b/tv/2configs/nets/hkw.nix @@ -1,65 +1,65 @@ { krebs = { - dns.providers.gg23 = "hosts"; + dns.providers.hkw = "hosts"; hosts = { nomic = { - nets.gg23 = { + nets.hkw = { ip4 = { addr = "10.23.1.110"; prefix = "10.23.1.0/24"; }; aliases = [ - "nomic.gg23" + "nomic.hkw" ]; ssh.port = 11423; }; }; ok = { external = true; - nets.gg23 = { + nets.hkw = { ip4 = { addr = "10.23.1.1"; prefix = "10.23.1.0/24"; }; aliases = [ - "ok.gg23" + "ok.hkw" ]; }; }; wu = { - nets.gg23 = { + nets.hkw = { ip4 = { addr = "10.23.1.37"; prefix = "10.23.1.0/24"; }; aliases = [ - "wu.gg23" - "cache.wu.gg23" + "wu.hkw" + "cache.wu.hkw" ]; ssh.port = 11423; }; }; xu = { - nets.gg23 = { + nets.hkw = { ip4 = { addr = "10.23.1.38"; prefix = "10.23.1.0/24"; }; aliases = [ - "xu.gg23" - "cache.xu.gg23" + "xu.hkw" + "cache.xu.hkw" ]; ssh.port = 11423; }; }; zu = { - nets.gg23 = { + nets.hkw = { ip4 = { addr = "10.23.1.39"; prefix = "10.23.1.0/24"; }; aliases = [ - "zu.gg23" + "zu.hkw" ]; ssh.port = 11423; }; diff --git a/tv/2configs/nginx/public_html.nix b/tv/2configs/nginx/public_html.nix index cc7a39891..a37498ba3 100644 --- a/tv/2configs/nginx/public_html.nix +++ b/tv/2configs/nginx/public_html.nix @@ -9,7 +9,7 @@ with import ; serverAliases = [ "localhost" "${config.krebs.build.host.name}" - "${config.krebs.build.host.name}.gg23" + "${config.krebs.build.host.name}.hkw" "${config.krebs.build.host.name}.r" ]; locations."~ ^/~(.+?)(/.*)?\$".extraConfig = ''