···379379380380- `services.maddy` got several updates:
381381 - Configuration of users and their credentials using `services.maddy.ensureCredentials`.
382382- - Configuration of TLS key and certificate files using `services.maddy.tls`.
382382+ - TLS configuration is now possible via `services.maddy.tls` with two loaders present: ACME and file based.
383383384384- The `dnsmasq` service now takes configuration via the
385385 `services.dnsmasq.settings` attribute set. The option
+60-19
nixos/modules/services/mail/maddy.nix
···206206 Server configuration, see
207207 [https://maddy.email](https://maddy.email) for
208208 more information. The default configuration of this module will setup
209209- minimal maddy instance for mail transfer without TLS encryption.
209209+ minimal Maddy instance for mail transfer without TLS encryption.
210210211211 ::: {.note}
212212 This should not be used in a production environment.
···216216217217 tls = {
218218 loader = mkOption {
219219- type = with types; nullOr (enum [ "file" "off" ]);
219219+ type = with types; nullOr (enum [ "off" "file" "acme" ]);
220220 default = "off";
221221 description = lib.mdDoc ''
222222 TLS certificates are obtained by modules called "certificate
223223- loaders". Currently only the file loader is supported which reads
224224- certificates from files specifying the options `keyPaths` and
225225- `certPaths`.
223223+ loaders".
224224+225225+ The `file` loader module reads certificates from files specified by
226226+ the `certificates` option.
227227+228228+ Alternatively the `acme` module can be used to automatically obtain
229229+ certificates using the ACME protocol.
230230+231231+ Module configuration is done via the `tls.extraConfig` option.
232232+233233+ Secrets such as API keys or passwords should not be supplied in
234234+ plaintext. Instead the `secrets` option can be used to read secrets
235235+ at runtime as environment variables. Secrets can be referenced with
236236+ `{env:VAR}`.
226237 '';
227238 };
228239···261272 extraConfig = mkOption {
262273 type = with types; nullOr lines;
263274 description = lib.mdDoc ''
264264- Arguments for the specific certificate loader. Note that Maddy uses
265265- secure defaults for the TLS configuration so there is no need to
266266- change anything in most cases.
267267- See [upstream manual](https://maddy.email/reference/tls/) for
268268- available options.
275275+ Arguments for the specified certificate loader.
276276+277277+ In case the `tls` loader is set, the defaults are considered secure
278278+ and there is no need to change anything in most cases.
279279+ For available options see [upstream manual](https://maddy.email/reference/tls/).
280280+281281+ For ACME configuration, see [following page](https://maddy.email/reference/tls-acme).
269282 '';
270283 default = "";
271284 };
···321334 });
322335 };
323336337337+ secrets = lib.mkOption {
338338+ type = lib.types.path;
339339+ description = lib.mdDoc ''
340340+ A file containing the various secrets. Should be in the format
341341+ expected by systemd's `EnvironmentFile` directory. Secrets can be
342342+ referenced in the format `{env:VAR}`.
343343+ '';
344344+ };
345345+324346 };
325347 };
326348327349 config = mkIf cfg.enable {
328350329329- assertions = [{
330330- assertion = cfg.tls.loader == "file" -> cfg.tls.certificates != [];
331331- message = ''
332332- If maddy is configured to use TLS, tls.certificates with attribute sets
333333- of certPath and keyPath must be provided.
334334- Read more about obtaining TLS certificates here:
335335- https://maddy.email/tutorials/setting-up/#tls-certificates
336336- '';
337337- }];
351351+ assertions = [
352352+ {
353353+ assertion = cfg.tls.loader == "file" -> cfg.tls.certificates != [];
354354+ message = ''
355355+ If Maddy is configured to use TLS, tls.certificates with attribute sets
356356+ of certPath and keyPath must be provided.
357357+ Read more about obtaining TLS certificates here:
358358+ https://maddy.email/tutorials/setting-up/#tls-certificates
359359+ '';
360360+ }
361361+ {
362362+ assertion = cfg.tls.loader == "acme" -> cfg.tls.extraConfig != "";
363363+ message = ''
364364+ If Maddy is configured to obtain TLS certificates using the ACME
365365+ loader, extra configuration options must be supplied via
366366+ tls.extraConfig option.
367367+ See upstream documentation for more details:
368368+ https://maddy.email/reference/tls-acme
369369+ '';
370370+ }
371371+ ];
338372339373 systemd = {
340374···345379 User = cfg.user;
346380 Group = cfg.group;
347381 StateDirectory = [ "maddy" ];
382382+ EnvironmentFile = lib.mkIf (cfg.secrets != null) "${cfg.secrets}";
348383 };
349384 restartTriggers = [ config.environment.etc."maddy/maddy.conf".source ];
350385 wantedBy = [ "multi-user.target" ];
···391426 ) cfg.tls.certificates)} ${optionalString (cfg.tls.extraConfig != "") ''
392427 { ${cfg.tls.extraConfig} }
393428 ''}
429429+ '' else if (cfg.tls.loader == "acme") then ''
430430+ tls {
431431+ loader acme {
432432+ ${cfg.tls.extraConfig}
433433+ }
434434+ }
394435 '' else if (cfg.tls.loader == "off") then ''
395436 tls off
396437 '' else ""}