~yoctocell/nixrc

ref: 1119786e9e54ae90e4dd05556dc8aa555672beff nixrc/profiles/mail/mailserver/default.nix -rw-r--r-- 2.2 KiB
1119786eXinglu Chen profiles: mailserver: Add lists. 8 months ago
                                                                                
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{ config, lib, pkgs, pr103973, ... }:
let
  passwords = import ../../../secrets/passwd.nix { };
in
{
  nixpkgs.overlays = [
    (final: prev: {
      rspamd = pr103973.rspamd;
    })
  ];


  mailserver = {
    enable = true;
    fqdn = "mail.yoctocell.xyz";
    domains = [ "yoctocell.xyz" ];

    loginAccounts = {
      "public@yoctocell.xyz" = {
        # mkpasswd -m sha-512
        hashedPassword = passwords.mail.publicPasswd;
        sieveScript = ''
          require ["variables", "envelope", "fileinto", "subaddress", "mailbox"];
          if anyof (header :contains ["List-Id"]
                      "<info-gnu-emacs.gnu.org>",
                    header :contains ["To","Cc"]
                      "info-gnu-emacs@gnu.org") {
            fileinto "list.emacs.announce";
          }
        '' + (builtins.readFile ./dovecot.sieve);
      };

      "private@yoctocell.xyz" = {
        # mkpasswd -m sha-512
        hashedPassword = passwords.mail.privatePasswd;
      };

      "lists@yoctocell.xyz" = {
        hashedPassword = passwords.mail.listsPasswd;
        sieveScript = ''
          require ["variables", "envelope", "fileinto", "subaddress", "mailbox"];
        
           if allof (header :matches ["Subject"]
             "Your confirmation is required to join*",
             header :contains ["To"] "lists@yoctocell.xyz") {
             fileinto "INBOX";
           }
           
           elsif allof (header :matches ["Subject"]
             "Welcome to the * list",
             header :contains ["To"] "lists@yoctocell.xyz") {
             fileinto "INBOX";
           }  

        '' + (builtins.readFile ./dovecot.sieve);
      };
    };

    mailboxes = {
      Trash = {
        auto = "no";
        specialUse = "Trash";
      };
      Junk = {
        auto = "subscribe";
        specialUse = "Junk";
      };
      Drafts = {
        auto = "subscribe";
        specialUse = "Drafts";
      };
      Sent = {
        auto = "subscribe";
        specialUse = "Sent";
      };
      Archive = {
        auto = "subscribe";
        specialUse = "Archive";
      };
    };

    # let's encrypt
    certificateScheme = 3;

    virusScanning = false;
  };

  networking.firewall.allowedTCPPorts = [ 465 993 ];
}