summary refs log tree commit diff
path: root/host/Rory-nginx/services/email/maddy.nix
blob: 995d6a255e000ea68713d5fa46fd06bd722312fb (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
{
  pkgs,
  options,
  config,
  ...
}:
{
  services.maddy = {
    enable = true;
    primaryDomain = "rory.gay";
    hostname = "mail.rory.gay";
    ensureAccounts = [
      "root@rory.gay"
    ];
    ensureCredentials = {
      "root@rory.gay".passwordFile = "/var/lib/maddy/passwd/root";
    };
    config =
      builtins.replaceStrings
        [
          "imap tcp://0.0.0.0:143"
          "submission tcp://0.0.0.0:587"
        ]
        [
          "imap tls://0.0.0.0:993 tcp://0.0.0.0:143"
          "submission tls://0.0.0.0:465 tcp://0.0.0.0:587"
        ]
        options.services.maddy.config.default;

    tls = {
      loader = "file";
      certificates = [
        "/var/lib/acme/certs/mail.rory.gay/fullchain.pem"
        "/var/lib/acme/certs/mail.rory.gay/privkey.pem"
      ];
    };
  };
  networking.firewall.allowedTCPPorts = [
    993
    465
  ];

  security.acme.certs."mail.rory.gay" = {
    group = config.services.maddy.group;
  };
}