]>
Commit | Line | Data |
---|---|---|
74a10960 | 1 | { lib, pkgs, config, name, ... }: |
af421a8f | 2 | { |
74a10960 | 3 | imports = |
ef43c362 IB |
4 | builtins.attrValues (import ../../../lib/flake-compat.nix ../../../flakes/private/openarc).nixosModules |
5 | ++ builtins.attrValues (import ../../../lib/flake-compat.nix ../../../flakes/private/opendmarc).nixosModules; | |
74a10960 | 6 | |
a929614f IB |
7 | options.myServices.mail.milters.sockets = lib.mkOption { |
8 | type = lib.types.attrsOf lib.types.path; | |
9 | default = { | |
10 | opendkim = "/run/opendkim/opendkim.sock"; | |
910c2e9e IB |
11 | opendmarc = config.services.opendmarc.socket; |
12 | openarc = config.services.openarc.socket; | |
af421a8f | 13 | }; |
a929614f IB |
14 | readOnly = true; |
15 | description = '' | |
16 | milters sockets | |
17 | ''; | |
af421a8f | 18 | }; |
619e4f46 | 19 | config = lib.mkIf (config.myServices.mail.enable || config.myServices.mailBackup.enable) { |
8415083e IB |
20 | secrets.keys = [ |
21 | { | |
22 | dest = "opendkim/eldiron.private"; | |
23 | user = config.services.opendkim.user; | |
24 | group = config.services.opendkim.group; | |
25 | permissions = "0400"; | |
ab8f306d | 26 | text = config.myEnv.mail.dkim.eldiron.private; |
8415083e IB |
27 | } |
28 | { | |
29 | dest = "opendkim/eldiron.txt"; | |
30 | user = config.services.opendkim.user; | |
31 | group = config.services.opendkim.group; | |
32 | permissions = "0444"; | |
33 | text = '' | |
ab8f306d | 34 | eldiron._domainkey IN TXT ${config.myEnv.mail.dkim.eldiron.public}''; |
8415083e | 35 | } |
411af8e3 | 36 | ]; |
8415083e IB |
37 | users.users."${config.services.opendkim.user}".extraGroups = [ "keys" ]; |
38 | services.opendkim = { | |
39 | enable = true; | |
40 | socket = "local:${config.myServices.mail.milters.sockets.opendkim}"; | |
41 | domains = builtins.concatStringsSep "," (lib.flatten (map | |
42 | (zone: map | |
43 | (e: "${e.domain}${lib.optionalString (e.domain != "") "."}${zone.name}") | |
44 | (zone.withEmail or []) | |
45 | ) | |
ab8f306d | 46 | config.myEnv.dns.masterZones |
8415083e IB |
47 | )); |
48 | keyPath = "${config.secrets.location}/opendkim"; | |
49 | selector = "eldiron"; | |
50 | configFile = pkgs.writeText "opendkim.conf" '' | |
619e4f46 IB |
51 | SubDomains yes |
52 | UMask 002 | |
53 | AlwaysAddARHeader yes | |
8415083e IB |
54 | ''; |
55 | group = config.services.postfix.group; | |
56 | }; | |
850adcf4 | 57 | systemd.services.opendkim.serviceConfig.Slice = "mail.slice"; |
8415083e IB |
58 | systemd.services.opendkim.preStart = lib.mkBefore '' |
59 | # Skip the prestart script as keys are handled in secrets | |
60 | exit 0 | |
411af8e3 | 61 | ''; |
8415083e IB |
62 | services.filesWatcher.opendkim = { |
63 | restart = true; | |
64 | paths = [ | |
65 | config.secrets.fullPaths."opendkim/eldiron.private" | |
66 | ]; | |
67 | }; | |
68 | ||
45730653 IB |
69 | systemd.services.milter_verify_from = { |
70 | description = "Verify from milter"; | |
71 | after = [ "network.target" ]; | |
72 | wantedBy = [ "multi-user.target" ]; | |
73 | ||
74 | serviceConfig = { | |
850adcf4 | 75 | Slice = "mail.slice"; |
45730653 IB |
76 | User = "postfix"; |
77 | Group = "postfix"; | |
78 | ExecStart = let python = pkgs.python3.withPackages (p: [ p.pymilter ]); | |
79 | in "${python}/bin/python ${./verify_from.py} -s /run/milter_verify_from/verify_from.sock"; | |
80 | RuntimeDirectory = "milter_verify_from"; | |
81 | }; | |
82 | }; | |
411af8e3 | 83 | }; |
af421a8f | 84 | } |