summaryrefslogtreecommitdiff
path: root/sys/ns/mx.nix
blob: 5c7d3d0dae22c0999c6ab41b06028c3d90e4c038 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{ 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 ];
      };
    }));
  };
}