1 { lib, pkgs, config, myconfig, ... }:
3 options.myServices.mail.milters.sockets = lib.mkOption {
4 type = lib.types.attrsOf lib.types.path;
6 opendkim = "/run/opendkim/opendkim.sock";
7 opendmarc = "/run/opendmarc/opendmarc.sock";
8 openarc = "/run/openarc/openarc.sock";
15 config = lib.mkIf config.myServices.mail.enable {
18 dest = "opendkim/eldiron.private";
19 user = config.services.opendkim.user;
20 group = config.services.opendkim.group;
22 text = myconfig.env.mail.dkim.eldiron.private;
25 dest = "opendkim/eldiron.txt";
26 user = config.services.opendkim.user;
27 group = config.services.opendkim.group;
30 eldiron._domainkey IN TXT ${myconfig.env.mail.dkim.eldiron.public}'';
33 dest = "opendmarc/ignore.hosts";
34 user = config.services.opendmarc.user;
35 group = config.services.opendmarc.group;
37 text = myconfig.env.mail.dmarc.ignore_hosts;
40 users.users."${config.services.opendkim.user}".extraGroups = [ "keys" ];
43 socket = "local:${config.myServices.mail.milters.sockets.opendkim}";
44 domains = builtins.concatStringsSep "," (lib.flatten (map
46 (e: "${e.domain}${lib.optionalString (e.domain != "") "."}${zone.name}")
47 (zone.withEmail or [])
49 myconfig.env.dns.masterZones
51 keyPath = "${config.secrets.location}/opendkim";
53 configFile = pkgs.writeText "opendkim.conf" ''
57 group = config.services.postfix.group;
59 systemd.services.opendkim.preStart = lib.mkBefore ''
60 # Skip the prestart script as keys are handled in secrets
63 services.filesWatcher.opendkim = {
66 config.secrets.fullPaths."opendkim/eldiron.private"
70 users.users."${config.services.opendmarc.user}".extraGroups = [ "keys" ];
71 services.opendmarc = {
73 socket = "local:${config.myServices.mail.milters.sockets.opendmarc}";
74 configFile = pkgs.writeText "opendmarc.conf" ''
77 FailureReportsBcc postmaster@localhost.immae.eu
78 FailureReportsOnNone true
79 FailureReportsSentBy postmaster@immae.eu
80 IgnoreAuthenticatedClients true
81 IgnoreHosts ${config.secrets.fullPaths."opendmarc/ignore.hosts"}
84 TrustedAuthservIDs HOSTNAME, immae.eu, nef2.ens.fr
87 group = config.services.postfix.group;
89 services.filesWatcher.opendmarc = {
92 config.secrets.fullPaths."opendmarc/ignore.hosts"
99 socket = "local:${config.myServices.mail.milters.sockets.openarc}";
100 group = config.services.postfix.group;
101 configFile = pkgs.writeText "openarc.conf" ''
102 AuthservID mail.immae.eu
104 KeyFile ${config.secrets.fullPaths."opendkim/eldiron.private"}
111 systemd.services.openarc.postStart = lib.optionalString
112 (lib.strings.hasPrefix "local:" config.services.openarc.socket) ''
113 while [ ! -S ${lib.strings.removePrefix "local:" config.services.openarc.socket} ]; do
116 chmod g+w ${lib.strings.removePrefix "local:" config.services.openarc.socket}
118 services.filesWatcher.openarc = {
121 config.secrets.fullPaths."opendkim/eldiron.private"