about summary refs log tree commit diff
path: root/modules/server/spectrum/postfix/default.nix
blob: 978cb47726e627f2c1c25bd5349b74e2556b54d0 (plain) (blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ pkgs, ... }:

{
  services.postfix.enable = true;
  services.postfix.enableSubmission = true;
  services.postfix.hostname = "atuin.qyliss.net";
  services.postfix.config.smtp_tls_loglevel = "1";
  services.postfix.config.smtpd_forbid_bare_newline = true;
  services.postfix.config.disable_mime_output_conversion = true;
  services.postfix.sslCert = "/var/lib/acme/spectrum-os.org/fullchain.pem";
  services.postfix.sslKey = "/var/lib/acme/spectrum-os.org/key.pem";
  services.postfix.rootAlias = "hi@alyssa.is";
  services.postfix.relayDomains = [ "hash:/var/lib/mailman/data/postfix_domains" ];
  services.postfix.config.transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
  services.postfix.localRecipients = []; # empty array causes NixOS to add $alias_maps
  services.postfix.config.mailbox_command = "${pkgs.coreutils}/bin/false";
  services.postfix.config.local_recipient_maps =
    [ "proxy:unix:passwd.byname" "hash:/var/lib/mailman/data/postfix_lmtp" ];

  services.postfix.destination =
    [ "atuin.qyliss.net" "qyliss.net" "spectrumos.org" "spectrum-os.org" ];
  services.postfix.extraAliases = ''
    abuse: root
    noc: root
    security: root
    hostmaster: root
    usenet: root
    news: root
    webmaster: root
    www: root
    uucp: root
    ftp: root
  '';

  services.postfix.enableHeaderChecks = true;

  # Local mail can be submitted without being filtered through SpamAssassin.
  services.postfix.masterConfig."::1:smtp" = {
    type = "inet";
    private = false;
    command = "smtpd";
  };

  services.postfix.masterConfig.smtp_inet.args =
    [ "-o" "content_filter=spamassassin" ];

  services.postfix.masterConfig.spamassassin = {
    privileged = true;
    chroot = false;
    command = "pipe";
    args = [
      "user=postfix-spamc"
      "argv=${pkgs.spamassassin}/bin/spamc"
      "-f"
      "-e"
      "/run/wrappers/bin/sendmail"
      "-oi"
      "-f"
      "\${sender}"
      "\${recipient}"
    ];
  };

  networking.firewall.allowedTCPPorts = [ 25 ];

  users.groups.postfix-spamc = {};
  users.users.postfix-spamc = {
    group = "postfix-spamc";
    isSystemUser = true;
  };
}