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".
main
Alyssa Ross 2 years ago
parent bfa9a7eb22
commit f4a0bb8334
No known key found for this signature in database
GPG Key ID: F9DBED4859B271C0
  1. 11
      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;

Loading…
Cancel
Save