From 1ca3113b5e6823104dcb7155caffb94be83d1995 Mon Sep 17 00:00:00 2001 From: kat witch Date: Thu, 12 Aug 2021 15:26:11 +0100 Subject: [PATCH] dns.isRoot for @ DNS --- depot/modules/home/network.nix | 11 +++++++++++ depot/modules/nixos/network.nix | 19 ++++++++++++++++++- depot/services/website/default.nix | 2 ++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/depot/modules/home/network.nix b/depot/modules/home/network.nix index 953767c1..fa291d9d 100644 --- a/depot/modules/home/network.nix +++ b/depot/modules/home/network.nix @@ -30,6 +30,16 @@ with lib; domain = mkOption { type = types.nullOr types.str; }; + out = { + identifierList = mkOption { + type = types.listOf types.str; + default = if config.enable then singleton config.domain ++ config.out.addressList else [ ]; + }; + addressList = mkOption { + type = types.listOf types.str; + default = if config.enable then concatMap (i: optional i.enable i.address) [ config.ipv4 config.ipv6 ] else [ ]; + }; + }; }; })); }; @@ -46,6 +56,7 @@ with lib; }; }; dns = { + isRoot = mkEnableOption "Is this system supposed to be the @ for the domain?"; email = mkOption { type = types.nullOr types.str; }; diff --git a/depot/modules/nixos/network.nix b/depot/modules/nixos/network.nix index 6e46c2f2..63c3cb5b 100644 --- a/depot/modules/nixos/network.nix +++ b/depot/modules/nixos/network.nix @@ -136,7 +136,24 @@ in { domain = v.subdomain; aaaa.address = v.ipv6.address; }) networksWithDomains; - in recordsV4 // recordsV6; + in mkMerge [ + recordsV4 + recordsV6 + (mkIf cfg.dns.isRoot { + "node_root_${config.networking.hostName}_v4" = { + enable = cfg.addresses.public.enable; + tld = cfg.dns.tld; + domain = "@"; + a.address = cfg.addresses.public.ipv4.address; + }; + "node_root_${config.networking.hostName}_v6" = { + enable = cfg.addresses.public.enable; + tld = cfg.dns.tld; + domain = "@"; + aaaa.address = cfg.addresses.public.ipv6.address; + }; + }) + ]; security.acme.certs = mkIf config.services.nginx.enable (mapAttrs' (n: v: nameValuePair "cert_${n}_${config.networking.hostName}" { diff --git a/depot/services/website/default.nix b/depot/services/website/default.nix index 7a610745..4a70ec97 100644 --- a/depot/services/website/default.nix +++ b/depot/services/website/default.nix @@ -1,6 +1,8 @@ { config, lib, pkgs, ... }: { + network.dns.isRoot = true; + services.nginx.virtualHosts = { "${config.network.dns.domain}" = { root = pkgs.kat-website;