about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2022-04-09 20:15:33 +0200
committerGitHub <noreply@github.com>2022-04-09 20:15:33 +0200
commit918a14988814948fc60ae69c830a00f72a91dbf4 (patch)
treecefb79d931fc1b708757fe65c3fca55e5829fb86
parent0eba1fd8409f75199cd345a81a2eda694415de17 (diff)
parentf4a0bb8334dbfef6e092078a78d78572ad3d6730 (diff)
Merge pull request #167322 from alyssais/mailman-webHosts
nixos/mailman: improve empty webHosts error
-rw-r--r--nixos/modules/services/mail/mailman.nix11
1 files changed, 9 insertions, 2 deletions
diff --git a/nixos/modules/services/mail/mailman.nix b/nixos/modules/services/mail/mailman.nix
index 263f3b159d25f..5ddc188884558 100644
--- a/nixos/modules/services/mail/mailman.nix
+++ b/nixos/modules/services/mail/mailman.nix
@@ -225,7 +225,14 @@ in {
               See <https://mailman.readthedocs.io/en/latest/src/mailman/docs/mta.html>.
             '';
           };
-    in (lib.optionals cfg.enablePostfix [
+    in [
+      { assertion = cfg.webHosts != [];
+        message = ''
+          services.mailman.serve.enable requires there to be at least one entry
+          in services.mailman.webHosts.
+        '';
+      }
+    ] ++ (lib.optionals cfg.enablePostfix [
       { assertion = postfix.enable;
         message = ''
           Mailman's default NixOS configuration requires Postfix to be enabled.
@@ -275,7 +282,7 @@ in {
           globals().update(json.load(f))
     '';
 
-    services.nginx = mkIf cfg.serve.enable {
+    services.nginx = mkIf (cfg.serve.enable && cfg.webHosts != []) {
       enable = mkDefault true;
       virtualHosts = lib.genAttrs cfg.webHosts (webHost: {
         locations = {