From f4a0bb8334dbfef6e092078a78d78572ad3d6730 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 2 Apr 2022 11:17:46 +0000 Subject: 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". --- nixos/modules/services/mail/mailman.nix | 11 +++++++++-- 1 file 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 . ''; }; - 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; -- cgit 1.4.1