aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flakes/openarc/flake.nix1
-rw-r--r--flakes/openarc/private.nix35
-rw-r--r--modules/private/mail/milters.nix35
3 files changed, 40 insertions, 31 deletions
diff --git a/flakes/openarc/flake.nix b/flakes/openarc/flake.nix
index bdb0358..9bc104d 100644
--- a/flakes/openarc/flake.nix
+++ b/flakes/openarc/flake.nix
@@ -75,6 +75,7 @@
75 }; 75 };
76 }) // { 76 }) // {
77 hydraJobs.build = nixpkgs.lib.genAttrs flake-utils.lib.defaultSystems (system: self.defaultPackage."${system}"); 77 hydraJobs.build = nixpkgs.lib.genAttrs flake-utils.lib.defaultSystems (system: self.defaultPackage."${system}");
78 nixosModules = (if builtins.pathExists ./private.nix then import ./private.nix nixpkgs else {});
78 nixosModule = { config, lib, pkgs, ... }: 79 nixosModule = { config, lib, pkgs, ... }:
79 let 80 let
80 cfg = config.services.openarc; 81 cfg = config.services.openarc;
diff --git a/flakes/openarc/private.nix b/flakes/openarc/private.nix
new file mode 100644
index 0000000..5244ca9
--- /dev/null
+++ b/flakes/openarc/private.nix
@@ -0,0 +1,35 @@
1pkgs:
2let
3 cfg = name': { config, lib, pkgs, name, ... }: lib.mkIf (name == name') {
4 services.openarc = {
5 enable = true;
6 user = "opendkim";
7 socket = "local:${config.myServices.mail.milters.sockets.openarc}";
8 group = config.services.postfix.group;
9 configFile = pkgs.writeText "openarc.conf" ''
10 AuthservID mail.immae.eu
11 Domain mail.immae.eu
12 KeyFile ${config.secrets.fullPaths."opendkim/eldiron.private"}
13 Mode sv
14 Selector eldiron
15 SoftwareHeader yes
16 Syslog Yes
17 '';
18 };
19 systemd.services.openarc.serviceConfig.Slice = "mail.slice";
20 systemd.services.openarc.postStart = lib.optionalString
21 (lib.strings.hasPrefix "local:" config.services.openarc.socket) ''
22 while [ ! -S ${lib.strings.removePrefix "local:" config.services.openarc.socket} ]; do
23 sleep 0.5
24 done
25 chmod g+w ${lib.strings.removePrefix "local:" config.services.openarc.socket}
26 '';
27 services.filesWatcher.openarc = {
28 restart = true;
29 paths = [
30 config.secrets.fullPaths."opendkim/eldiron.private"
31 ];
32 };
33 };
34in
35 pkgs.lib.genAttrs ["eldiron" "backup-2"] cfg
diff --git a/modules/private/mail/milters.nix b/modules/private/mail/milters.nix
index 02c35c8..96c2800 100644
--- a/modules/private/mail/milters.nix
+++ b/modules/private/mail/milters.nix
@@ -1,5 +1,8 @@
1{ lib, pkgs, config, ... }: 1{ lib, pkgs, config, name, ... }:
2{ 2{
3 imports =
4 builtins.attrValues (import ../../../lib/flake-compat.nix ../../../flakes/openarc).nixosModules;
5
3 options.myServices.mail.milters.sockets = lib.mkOption { 6 options.myServices.mail.milters.sockets = lib.mkOption {
4 type = lib.types.attrsOf lib.types.path; 7 type = lib.types.attrsOf lib.types.path;
5 default = { 8 default = {
@@ -103,36 +106,6 @@
103 ]; 106 ];
104 }; 107 };
105 108
106 services.openarc = {
107 enable = true;
108 user = "opendkim";
109 socket = "local:${config.myServices.mail.milters.sockets.openarc}";
110 group = config.services.postfix.group;
111 configFile = pkgs.writeText "openarc.conf" ''
112 AuthservID mail.immae.eu
113 Domain mail.immae.eu
114 KeyFile ${config.secrets.fullPaths."opendkim/eldiron.private"}
115 Mode sv
116 Selector eldiron
117 SoftwareHeader yes
118 Syslog Yes
119 '';
120 };
121 systemd.services.openarc.serviceConfig.Slice = "mail.slice";
122 systemd.services.openarc.postStart = lib.optionalString
123 (lib.strings.hasPrefix "local:" config.services.openarc.socket) ''
124 while [ ! -S ${lib.strings.removePrefix "local:" config.services.openarc.socket} ]; do
125 sleep 0.5
126 done
127 chmod g+w ${lib.strings.removePrefix "local:" config.services.openarc.socket}
128 '';
129 services.filesWatcher.openarc = {
130 restart = true;
131 paths = [
132 config.secrets.fullPaths."opendkim/eldiron.private"
133 ];
134 };
135
136 systemd.services.milter_verify_from = { 109 systemd.services.milter_verify_from = {
137 description = "Verify from milter"; 110 description = "Verify from milter";
138 after = [ "network.target" ]; 111 after = [ "network.target" ];