diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-04-02 11:17:46 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2022-04-05 10:18:57 +0000 |
commit | f4a0bb8334dbfef6e092078a78d78572ad3d6730 (patch) | |
tree | 247b8f5d7c5c26746cb3390f80a60763897795d4 | |
parent | bfa9a7eb22df4d2c0946f1da00ae0f8ea801d155 (diff) |
nixos/mailman: improve empty webHosts error
Now this configuration mistake will generate the assertion message, instead of "error: list index 0 is out of bounds".
-rw-r--r-- | nixos/modules/services/mail/mailman.nix | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/nixos/modules/services/mail/mailman.nix b/nixos/modules/services/mail/mailman.nix index 0c9b38b44b24d..2183f22cbde8c 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.head cfg.webHosts}" = { serverAliases = cfg.webHosts; |