summary refs log tree commit diff
path: root/host/Rory-nginx/services/email/maddy.nix
blob: ac8c7fb0e1603a1ee2fe5b80ecf59eddadf844ef (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
{
  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 = [
        {
          certPath = "/var/lib/acme/mail.rory.gay/fullchain.pem";
          keyPath = "/var/lib/acme/mail.rory.gay/key.pem";
        }
      ];
    };
  };
  networking.firewall.allowedTCPPorts = [
    993
    465
  ];

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

  users.users.maddy.extraGroups = [ "nginx" ];
}