···274274 replacement. It stores backups as volume dump files and thus better integrates
275275 into contemporary backup solutions.
276276277277+- `services.maddy` now allows to configure users and their credentials using `services.maddy.ensureCredentials`.
278278+277279- The `dnsmasq` service now takes configuration via the
278280 `services.dnsmasq.settings` attribute set. The option
279281 `services.dnsmasq.extraConfig` will be deprecated when NixOS 22.11 reaches
+36-2
nixos/modules/services/mail/maddy.nix
···228228 default = [];
229229 description = lib.mdDoc ''
230230 List of IMAP accounts which get automatically created. Note that for
231231- a complete setup, user credentials for these accounts are required too
232232- and can be created using the command `maddyctl creds`.
231231+ a complete setup, user credentials for these accounts are required
232232+ and can be created using the `ensureCredentials` option.
233233 This option does not delete accounts which are not (anymore) listed.
234234 '';
235235 example = [
···238238 ];
239239 };
240240241241+ ensureCredentials = mkOption {
242242+ default = {};
243243+ description = lib.mdDoc ''
244244+ List of user accounts which get automatically created if they don't
245245+ exist yet. Note that for a complete setup, corresponding mail boxes
246246+ have to get created using the `ensureAccounts` option.
247247+ This option does not delete accounts which are not (anymore) listed.
248248+ '';
249249+ example = {
250250+ "user1@localhost".passwordFile = /secrets/user1-localhost;
251251+ "user2@localhost".passwordFile = /secrets/user2-localhost;
252252+ };
253253+ type = types.attrsOf (types.submodule {
254254+ options = {
255255+ passwordFile = mkOption {
256256+ type = types.path;
257257+ example = "/path/to/file";
258258+ default = null;
259259+ description = lib.mdDoc ''
260260+ Specifies the path to a file containing the
261261+ clear text password for the user.
262262+ '';
263263+ };
264264+ };
265265+ });
266266+ };
267267+241268 };
242269 };
243270···264291 ${pkgs.maddy}/bin/maddyctl imap-acct create ${account}
265292 fi
266293 '') cfg.ensureAccounts}
294294+ ''}
295295+ ${optionalString (cfg.ensureCredentials != {}) ''
296296+ ${concatStringsSep "\n" (mapAttrsToList (name: cfg: ''
297297+ if ! ${pkgs.maddy}/bin/maddyctl creds list | grep "${name}"; then
298298+ ${pkgs.maddy}/bin/maddyctl creds create --password $(cat ${escapeShellArg cfg.passwordFile}) ${name}
299299+ fi
300300+ '') cfg.ensureCredentials)}
267301 ''}
268302 '';
269303 serviceConfig = {
+5-3
nixos/tests/maddy.nix
···1010 primaryDomain = "server";
1111 openFirewall = true;
1212 ensureAccounts = [ "postmaster@server" ];
1313+ ensureCredentials = {
1414+ # Do not use this in production. This will make passwords world-readable
1515+ # in the Nix store
1616+ "postmaster@server".passwordFile = "${pkgs.writeText "postmaster" "test"}";
1717+ };
1318 };
1419 };
1520···4954 server.wait_for_unit("maddy.service")
5055 server.wait_for_open_port(143)
5156 server.wait_for_open_port(587)
5252-5353- server.succeed("maddyctl creds create --password test postmaster@server")
5454-5557 client.succeed("send-testmail")
5658 client.succeed("test-imap")
5759 '';