2022-12-04 13:45:43 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2022-11-17 12:06:16 +00:00
|
|
|
mail_config = config.mailserver;
|
|
|
|
acmeRoot = "/var/lib/acme/acme-challenge";
|
|
|
|
in {
|
2022-12-04 13:45:43 +00:00
|
|
|
config = lib.mkIf (mail_config.enable && mail_config.ssl_config.useACME) {
|
2022-11-17 12:06:16 +00:00
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts."${mail_config.fqdn}" = {
|
|
|
|
serverName = mail_config.fqdn;
|
|
|
|
serverAliases = mail_config.domains;
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
acmeRoot = acmeRoot;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
security.acme.certs."${mail_config.fqdn}" = {
|
2022-12-04 13:45:43 +00:00
|
|
|
reloadServices = ["postfix.service" "dovecot2.service"];
|
2022-11-17 12:06:16 +00:00
|
|
|
};
|
2022-12-04 13:45:43 +00:00
|
|
|
};
|
2022-11-17 12:06:16 +00:00
|
|
|
}
|