aboutsummaryrefslogtreecommitdiff
path: root/modules/private/mail/default.nix
blob: 839939c37a87d50b47ad14a1e9c9f613954d21ba (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
{ lib, pkgs, config,  ... }:
{
  imports = [
    ./milters.nix
    ./postfix.nix
    ./dovecot.nix
    ./rspamd.nix
  ];
  options.myServices.mail.enable = lib.mkEnableOption "enable Mail services";

  config = lib.mkIf config.myServices.mail.enable {
    security.acme.certs."mail" = config.myServices.certificates.certConfig // {
      domain = "eldiron.immae.eu";
      extraDomains = let
        zonesWithMx = builtins.filter (zone:
          lib.attrsets.hasAttr "withEmail" zone && lib.lists.length zone.withEmail > 0
        ) config.myEnv.dns.masterZones;
        mxs = map (zone: "mx-1.${zone.name}") zonesWithMx;
      in builtins.listToAttrs (map (mx: lib.attrsets.nameValuePair mx null) mxs);
    };
    services.duplyBackup.profiles = {
      mail = {
        rootDir = "/var/lib";
        excludeFile = lib.mkAfter ''
          + /var/lib/vhost
          - /var/lib
          '';
      };
    };
  };
}