From 9cb022698e629c59e984c10e9cd7e123eab1fbda Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 29 Dec 2022 17:33:07 +0100 Subject: kartei tv: move around hostFiles & co. --- kartei/tv/default.nix | 84 +++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 46 deletions(-) (limited to 'kartei') diff --git a/kartei/tv/default.nix b/kartei/tv/default.nix index c43c7cba..eacb40af 100644 --- a/kartei/tv/default.nix +++ b/kartei/tv/default.nix @@ -1,47 +1,5 @@ with import ../../lib; -{ config, ... }: let - - evalHost = hostName: hostConfig: evalSubmodule types.host [ - hostConfig - { - name = hostName; - owner = config.krebs.users.tv; - } - (optionalAttrs (hasAttrByPath ["nets" "retiolum"] hostConfig) { - nets.retiolum = { - ip6.addr = - (krebs.genipv6 "retiolum" "tv" { inherit hostName; }).address; - }; - }) - (let - pubkey-path = ./wiregrill + "/${hostName}.pub"; - in optionalAttrs (pathExists pubkey-path) { - nets.wiregrill = { - aliases = [ - "${hostName}.w" - ]; - ip6.addr = - (krebs.genipv6 "wiregrill" "tv" { inherit hostName; }).address; - wireguard.pubkey = readFile pubkey-path; - }; - }) - (host: mkIf (host.config.ssh.pubkey != null) { - ssh.privkey = mapAttrs (const mkDefault) { - path = config.krebs.secret.file "ssh.id_${host.config.ssh.privkey.type}"; - type = head (toList (match "ssh-([^ ]+) .*" host.config.ssh.pubkey)); - }; - }) - ]; - - hostFiles = - mapAttrs' - (name: type: { - name = removeSuffix ".nix" name; - value = ./hosts + "/${name}"; - }) - (readDir ./hosts); - -in { +{ config, ... }: { dns.providers = { "viljetic.de" = "regfish"; }; @@ -53,9 +11,43 @@ in { lambda = hostSource { inherit config lib; }; set = hostSource; }; - in - evalHost hostName hostConfig) - hostFiles; + in evalSubmodule types.host [ + hostConfig + { + name = hostName; + owner = config.krebs.users.tv; + } + (optionalAttrs (hasAttrByPath ["nets" "retiolum"] hostConfig) { + nets.retiolum = { + ip6.addr = + (krebs.genipv6 "retiolum" "tv" { inherit hostName; }).address; + }; + }) + (let + pubkey-path = ./wiregrill + "/${hostName}.pub"; + in optionalAttrs (pathExists pubkey-path) { + nets.wiregrill = { + aliases = [ + "${hostName}.w" + ]; + ip6.addr = + (krebs.genipv6 "wiregrill" "tv" { inherit hostName; }).address; + wireguard.pubkey = readFile pubkey-path; + }; + }) + (host: mkIf (host.config.ssh.pubkey != null) { + ssh.privkey = mapAttrs (const mkDefault) { + path = config.krebs.secret.file "ssh.id_${host.config.ssh.privkey.type}"; + type = head (toList (match "ssh-([^ ]+) .*" host.config.ssh.pubkey)); + }; + }) + ]) + (mapAttrs' + (name: type: { + name = removeSuffix ".nix" name; + value = ./hosts + "/${name}"; + }) + (readDir ./hosts)); sitemap = { "http://cgit.krebsco.de" = { desc = "Git repositories"; -- cgit v1.2.3