dns.isRoot for @ DNS

This commit is contained in:
kat witch 2021-08-12 15:26:11 +01:00
parent 226c77c970
commit 1ca3113b5e
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
3 changed files with 31 additions and 1 deletions

View file

@ -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;
};

View file

@ -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}" {

View file

@ -1,6 +1,8 @@
{ config, lib, pkgs, ... }:
{
network.dns.isRoot = true;
services.nginx.virtualHosts = {
"${config.network.dns.domain}" = {
root = pkgs.kat-website;