about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/mail
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-01-09 19:24:41 +0000
committerAlyssa Ross <hi@alyssa.is>2020-01-09 20:51:29 +0000
commit6af7a8664792d64aa430ef57aace487229e149ff (patch)
tree84d34c08afbb926f089194e19f8d39c268fcb546 /nixpkgs/nixos/modules/services/mail
parent2ca27589e7b0a83aab914e3202574b2a7bfd2a36 (diff)
downloadnixlib-6af7a8664792d64aa430ef57aace487229e149ff.tar
nixlib-6af7a8664792d64aa430ef57aace487229e149ff.tar.gz
nixlib-6af7a8664792d64aa430ef57aace487229e149ff.tar.bz2
nixlib-6af7a8664792d64aa430ef57aace487229e149ff.tar.lz
nixlib-6af7a8664792d64aa430ef57aace487229e149ff.tar.xz
nixlib-6af7a8664792d64aa430ef57aace487229e149ff.tar.zst
nixlib-6af7a8664792d64aa430ef57aace487229e149ff.zip
nixos/mailman: don't set Postfix hashes
It's likely that a user might want to set multiple values for
relay_domains, transport_maps, and local_recipient_maps, and the order
is significant.  This means that there's no good way to set these
across multiple NixOS modules, and they should probably all be set
together in the user's Postfix configuration.

So, rather than setting these in the Mailman module, just make the
Mailman module check that the values it needs to occur somewhere, and
advise the user on what to set if not.
Diffstat (limited to 'nixpkgs/nixos/modules/services/mail')
-rw-r--r--nixpkgs/nixos/modules/services/mail/mailman.nix26
1 files changed, 21 insertions, 5 deletions
diff --git a/nixpkgs/nixos/modules/services/mail/mailman.nix b/nixpkgs/nixos/modules/services/mail/mailman.nix
index 7553f3bc7a8c..d1b730d36f45 100644
--- a/nixpkgs/nixos/modules/services/mail/mailman.nix
+++ b/nixpkgs/nixos/modules/services/mail/mailman.nix
@@ -150,10 +150,29 @@ in {
 
   config = mkIf cfg.enable {
 
-    assertions = [
-      { assertion = cfg.enable -> config.services.postfix.enable;
+    assertions = let
+      inherit (config.services) postfix;
+
+      requirePostfixHash = optionPath: dataFile:
+        with lib;
+        let
+          value = "hash:/var/lib/mailman/data/${dataFile}";
+        in
+          { assertion =
+              postfix.enable -> elem value (attrByPath optionPath [] postfix);
+            message = ''
+              services.postfix.${concatStringsSep "." optionPath} must contain
+              "${value}".
+              See <https://mailman.readthedocs.io/en/latest/src/mailman/docs/mta.html>.
+            '';
+          };
+    in [
+      { assertion = postfix.enable;
         message = "Mailman requires Postfix";
       }
+      (requirePostfixHash [ "relayDomains" ] "postfix_domains")
+      (requirePostfixHash [ "config" "transport_maps" ] "postfix_lmtp")
+      (requirePostfixHash [ "config" "local_recipient_maps" ] "postfix_lmtp")
     ];
 
     users.users.mailman = { description = "GNU Mailman"; isSystemUser = true; };
@@ -164,11 +183,8 @@ in {
     };
 
     services.postfix = {
-      relayDomains = [ "hash:/var/lib/mailman/data/postfix_domains" ];
       recipientDelimiter = "+";         # bake recipient addresses in mail envelopes via VERP
       config = {
-        transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
-        local_recipient_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
         owner_request_special = "no";   # Mailman handles -owner addresses on its own
       };
     };