DNS: autogenerate CNAMES from nginx config

This commit is contained in:
Rouven Seifert 2024-04-18 19:49:40 +02:00
parent ee02192290
commit 43a4843551
Signed by: rouven.seifert
GPG key ID: B95E8FE6B11C4D09

View file

@ -2,7 +2,8 @@
let
modulo = number: mod: (number - ((number / mod) * mod));
secondary = "185.181.104.96";
zonefile = with dns.lib.combinators; pkgs.writeText "rfive.de.zone.txt" (dns.lib.toString "rfive.de" {
domain = config.networking.domain;
zonefile = with dns.lib.combinators; pkgs.writeText "rfive.de.zone.txt" (dns.lib.toString domain {
TTL = 3600;
SOA = {
nameServer = "ns.rfive.de.";
@ -44,8 +45,8 @@ let
_domainkey.subdomains.rspamd.TXT = [ "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDoirUMubro4nlmY6a8JMwK9QB2agAXiJzexDU/7ba6KCggONfoSTfUHlrM/XeM1GG/9oKpngApxDPP97adJuxc8/EELyo4HjTyYD8GBFZhg0AN7V8IPaJ1o5k6dGDk8ZLh41ZCnlAVWkhVSKs5pYtzkrlJIfUSzyuoe8nuFsVe3QIDAQAB" ];
}
(lib.attrsets.genAttrs [ "cache" "chat" "matrix" "seafile" "vault" ] (label: { CNAME = [ "nuc.rfive.de." ]; }))
(lib.attrsets.genAttrs [ "purge" "rspamd" "trucks" ] (label: { CNAME = [ "falkenstein.rfive.de." ]; }))
(lib.attrsets.genAttrs (map (name: builtins.substring 0 (builtins.stringLength name - (builtins.stringLength domain + 1)) name) (builtins.attrNames self.nixosConfigurations.nuc.config.services.nginx.virtualHosts)) (label: { CNAME = [ "nuc.rfive.de." ]; }))
(lib.attrsets.genAttrs (map (name: builtins.substring 0 (builtins.stringLength name - (builtins.stringLength domain + 1)) name) (builtins.attrNames self.nixosConfigurations.falkenstein.config.services.nginx.virtualHosts)) (label: { CNAME = [ "falkenstein.rfive.de." ]; }))
];
});
in