mirror of
https://git.sr.ht/~rouven/nixos-config
synced 2024-11-15 05:13:10 +01:00
dns: keep things DRY
This commit is contained in:
parent
43a4843551
commit
8f0a5e1a8a
|
@ -216,11 +216,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1713294767,
|
"lastModified": 1713453913,
|
||||||
"narHash": "sha256-LmaabaQZdx52MPGKPRt9Opoc9Gd9RbwvCdysUUYQoXI=",
|
"narHash": "sha256-vbXq52VRlL1defMHrwhsoeHm95O3mFefsSSJyNEghbA=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "fa8c16e2452bf092ac76f09ee1fb1e9f7d0796e7",
|
"rev": "178e26895b3aef028a00a32fb7e7ed0fc660645c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
{ self, pkgs, lib, config, dns, ... }:
|
{ self, pkgs, lib, config, dns, ... }:
|
||||||
let
|
let
|
||||||
modulo = number: mod: (number - ((number / mod) * mod));
|
|
||||||
secondary = "185.181.104.96";
|
secondary = "185.181.104.96";
|
||||||
domain = config.networking.domain;
|
domain = config.networking.domain;
|
||||||
zonefile = with dns.lib.combinators; pkgs.writeText "rfive.de.zone.txt" (dns.lib.toString domain {
|
zonefile = with dns.lib.combinators; pkgs.writeText "rfive.de.zone.txt" (dns.lib.toString domain {
|
||||||
TTL = 3600;
|
TTL = 3600;
|
||||||
SOA = {
|
SOA =
|
||||||
|
let
|
||||||
|
modulo = number: mod: (number - ((number / mod) * mod));
|
||||||
|
in
|
||||||
|
{
|
||||||
nameServer = "ns.rfive.de.";
|
nameServer = "ns.rfive.de.";
|
||||||
adminEmail = "hostmaster@rfive.de";
|
adminEmail = "hostmaster@rfive.de";
|
||||||
serial = lib.strings.toInt (builtins.substring 0 8 self.sourceInfo.lastModifiedDate + toString ((modulo self.sourceInfo.lastModified 86400) / 864));
|
serial = lib.strings.toInt (builtins.substring 0 8 self.sourceInfo.lastModifiedDate + toString ((modulo self.sourceInfo.lastModified 86400) / 864));
|
||||||
|
@ -30,7 +33,12 @@ let
|
||||||
(spf.soft [ "mx" ])
|
(spf.soft [ "mx" ])
|
||||||
];
|
];
|
||||||
|
|
||||||
subdomains = lib.attrsets.mergeAttrsList [
|
subdomains =
|
||||||
|
let
|
||||||
|
getVirtualHosts = hostname: map (name: builtins.substring 0 (builtins.stringLength name - (builtins.stringLength domain + 1)) name) (builtins.attrNames self.nixosConfigurations."${hostname}".config.services.nginx.virtualHosts);
|
||||||
|
genCNAMEs = hostname: lib.attrsets.genAttrs (getVirtualHosts hostname) (label: { CNAME = [ "${hostname}.${domain}." ]; });
|
||||||
|
in
|
||||||
|
lib.attrsets.mergeAttrsList [
|
||||||
rec {
|
rec {
|
||||||
nuc = {
|
nuc = {
|
||||||
A = [ "141.30.227.6" ];
|
A = [ "141.30.227.6" ];
|
||||||
|
@ -45,8 +53,8 @@ let
|
||||||
_domainkey.subdomains.rspamd.TXT = [ "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDoirUMubro4nlmY6a8JMwK9QB2agAXiJzexDU/7ba6KCggONfoSTfUHlrM/XeM1GG/9oKpngApxDPP97adJuxc8/EELyo4HjTyYD8GBFZhg0AN7V8IPaJ1o5k6dGDk8ZLh41ZCnlAVWkhVSKs5pYtzkrlJIfUSzyuoe8nuFsVe3QIDAQAB" ];
|
_domainkey.subdomains.rspamd.TXT = [ "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDoirUMubro4nlmY6a8JMwK9QB2agAXiJzexDU/7ba6KCggONfoSTfUHlrM/XeM1GG/9oKpngApxDPP97adJuxc8/EELyo4HjTyYD8GBFZhg0AN7V8IPaJ1o5k6dGDk8ZLh41ZCnlAVWkhVSKs5pYtzkrlJIfUSzyuoe8nuFsVe3QIDAQAB" ];
|
||||||
|
|
||||||
}
|
}
|
||||||
(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." ]; }))
|
(genCNAMEs "nuc")
|
||||||
(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." ]; }))
|
(genCNAMEs "falkenstein")
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
|
|
Loading…
Reference in a new issue