···274 replacement. It stores backups as volume dump files and thus better integrates
275 into contemporary backup solutions.
27600277- The `dnsmasq` service now takes configuration via the
278 `services.dnsmasq.settings` attribute set. The option
279 `services.dnsmasq.extraConfig` will be deprecated when NixOS 22.11 reaches
···274 replacement. It stores backups as volume dump files and thus better integrates
275 into contemporary backup solutions.
276277+- `services.maddy` now allows to configure users and their credentials using `services.maddy.ensureCredentials`.
278+279- The `dnsmasq` service now takes configuration via the
280 `services.dnsmasq.settings` attribute set. The option
281 `services.dnsmasq.extraConfig` will be deprecated when NixOS 22.11 reaches
+36-2
nixos/modules/services/mail/maddy.nix
···228 default = [];
229 description = lib.mdDoc ''
230 List of IMAP accounts which get automatically created. Note that for
231- a complete setup, user credentials for these accounts are required too
232- and can be created using the command `maddyctl creds`.
233 This option does not delete accounts which are not (anymore) listed.
234 '';
235 example = [
···238 ];
239 };
240000000000000000000000000000241 };
242 };
243···264 ${pkgs.maddy}/bin/maddyctl imap-acct create ${account}
265 fi
266 '') cfg.ensureAccounts}
0000000267 ''}
268 '';
269 serviceConfig = {
···228 default = [];
229 description = lib.mdDoc ''
230 List of IMAP accounts which get automatically created. Note that for
231+ a complete setup, user credentials for these accounts are required
232+ and can be created using the `ensureCredentials` option.
233 This option does not delete accounts which are not (anymore) listed.
234 '';
235 example = [
···238 ];
239 };
240241+ ensureCredentials = mkOption {
242+ default = {};
243+ description = lib.mdDoc ''
244+ List of user accounts which get automatically created if they don't
245+ exist yet. Note that for a complete setup, corresponding mail boxes
246+ have to get created using the `ensureAccounts` option.
247+ This option does not delete accounts which are not (anymore) listed.
248+ '';
249+ example = {
250+ "user1@localhost".passwordFile = /secrets/user1-localhost;
251+ "user2@localhost".passwordFile = /secrets/user2-localhost;
252+ };
253+ type = types.attrsOf (types.submodule {
254+ options = {
255+ passwordFile = mkOption {
256+ type = types.path;
257+ example = "/path/to/file";
258+ default = null;
259+ description = lib.mdDoc ''
260+ Specifies the path to a file containing the
261+ clear text password for the user.
262+ '';
263+ };
264+ };
265+ });
266+ };
267+268 };
269 };
270···291 ${pkgs.maddy}/bin/maddyctl imap-acct create ${account}
292 fi
293 '') cfg.ensureAccounts}
294+ ''}
295+ ${optionalString (cfg.ensureCredentials != {}) ''
296+ ${concatStringsSep "\n" (mapAttrsToList (name: cfg: ''
297+ if ! ${pkgs.maddy}/bin/maddyctl creds list | grep "${name}"; then
298+ ${pkgs.maddy}/bin/maddyctl creds create --password $(cat ${escapeShellArg cfg.passwordFile}) ${name}
299+ fi
300+ '') cfg.ensureCredentials)}
301 ''}
302 '';
303 serviceConfig = {