{ config, lib, ... }: with lib; let inherit (config.local) domains; in { options.local.ns.zones = mkOption { type = with lib.types; attrsOf (submodule ({ config, name, ... }: { options.localMX = { enable = mkEnableOption "local MX settings"; }; config = mkIf config.localMX.enable { mx = [ { name = "@"; priority = 10; host = "${domains.smtp.main}."; } { name = "@"; priority = 20; host = "mxbackup1.junkemailfilter.com."; } { name = "@"; priority = 30; host = "mxbackup2.junkemailfilter.com."; } ]; txt = [ { name = "@"; text = "v=spf1 mx a -all"; } { name = "_dmarc"; text = "v=DMARC1;p=reject;sp=reject;adkim=r;aspf=r;fo=1;rf=afrf;rua=mailto:postmaster@${name}"; } { name = "_adsp._domainkey"; text = "dkim=all"; } ] ++ map (selector: { name = "${toString selector}._domainkey"; text = readFile (./dkim + "/${toString selector}.txt"); }) [ 202001 202102 202402 202408 ]; }; })); }; }