Change:
# Rudimentary test checking that the Stalwart email server can: # - receive some message through SMTP submission, then # - serve this message through IMAP. <ins> { system ? builtins.currentSystem, config ? { }, pkgs ? import ../../.. { inherit system config; }, lib ? pkgs.lib, }: </ins> let certs = import ./common/acme/server/snakeoil-certs.nix; domain = certs.domain; <del> in import ./make-test-python.nix ({ lib, ... }: { name = "stalwart-mail"; nodes.main = { pkgs, ... }: { security.pki.certificateFiles = [ certs.ca.cert ]; services.stalwart-mail = { enable = true; settings = { server.hostname = domain; certificate."snakeoil" = { cert = "file://${certs.${domain}.cert}"; private-key = "file://${certs.${domain}.key}"; }; server.tls = { certificate = "snakeoil"; </del> <ins> makeTest = import ./make-test-python.nix; mkTestName = pkg: "${pkg.pname}_${pkg.version}"; stalwartPackages = { inherit (pkgs) stalwart-mail_0_6 stalwart-mail; }; stalwartAtLeast = lib.versionAtLeast; makeStalwartTest = { package, name ? mkTestName package, }: makeTest { inherit name; meta.maintainers = with lib.maintainers; [ happysalada pacien onny ]; nodes.machine = { lib, ... }: { security.pki.certificateFiles = [ certs.ca.cert ]; services.stalwart-mail = { </ins> enable = true; <del> implicit = false; }; server.listener = { "smtp-submission" = { bind = [ "[::]:587" ]; protocol = "smtp"; }; "imap" = { bind = [ "[::]:143" ]; protocol = "imap"; </del> <ins> inherit package; settings = { server.hostname = domain; # TODO: Remove backwards compatibility as soon as we drop legacy version 0.6.0 certificate."snakeoil" = let certPath = if stalwartAtLeast package.version "0.7.0" then "%{file://${certs.${domain}.cert}}%" else "file://${certs.${domain}.cert}"; keyPath = if stalwartAtLeast package.version "0.7.0" then "%{file:${certs.${domain}.key}}%" else "file://${certs.${domain}.key}"; in { cert = certPath; private-key = keyPath; }; server.tls = { certificate = "snakeoil"; enable = true; implicit = false; }; server.listener = { "smtp-submission" = { bind = [ "[::]:587" ]; protocol = "smtp"; }; "imap" = { bind = [ "[::]:143" ]; protocol = "imap"; }; }; session.auth.mechanisms = "[plain]"; session.auth.directory = "'in-memory'"; storage.directory = "in-memory"; session.rcpt.directory = "'in-memory'"; queue.outbound.next-hop = "'local'"; directory."in-memory" = { type = "memory"; # TODO: Remove backwards compatibility as soon as we drop legacy version 0.6.0 principals = let condition = if stalwartAtLeast package.version "0.7.0" then "class" else "type"; in builtins.map (p: p // { ${condition} = "individual"; }) [ { name = "alice"; secret = "foobar"; email = [ "alice@${domain}" ]; } { name = "bob"; secret = "foobar"; email = [ "bob@${domain}" ]; } ]; }; </ins> }; }; <del> resolver.public-suffix = [ ];  # do not fetch from web in sandbox session.auth.mechanisms = "[plain]"; session.auth.directory = "'in-memory'"; storage.directory = "in-memory"; session.rcpt.directory = "'in-memory'"; queue.outbound.next-hop = "'local'"; directory."in-memory" = { type = "memory"; principals = [ { type = "individual"; name = "alice"; secret = "foobar"; email = [ "alice@${domain}" ]; } { type = "individual"; name = "bob"; secret = "foobar"; email = [ "bob@${domain}" ]; } ]; }; }; }; </del> <ins> environment.systemPackages = [ (pkgs.writers.writePython3Bin "test-smtp-submission" { } '' from smtplib import SMTP with SMTP('localhost', 587) as smtp: smtp.starttls() smtp.login('alice', 'foobar') smtp.sendmail( 'alice@${domain}', 'bob@${domain}', """ From: alice@${domain} To: bob@${domain} Subject: Some test message This is a test message. """.strip() ) '') (pkgs.writers.writePython3Bin "test-imap-read" { } '' from imaplib import IMAP4 with IMAP4('localhost') as imap: imap.starttls() status, [caps] = imap.login('bob', 'foobar') assert status == 'OK' imap.select() status, [ref] = imap.search(None, 'ALL') assert status == 'OK' [msgId] = ref.split() status, msg = imap.fetch(msgId, 'BODY[TEXT]') assert status == 'OK' assert msg[0][1].strip() == b'This is a test message.' '') ]; </ins> <del> environment.systemPackages = [ (pkgs.writers.writePython3Bin "test-smtp-submission" { } '' from smtplib import SMTP with SMTP('localhost', 587) as smtp: smtp.starttls() smtp.login('alice', 'foobar') smtp.sendmail( 'alice@${domain}', 'bob@${domain}', """ From: alice@${domain} To: bob@${domain} Subject: Some test message This is a test message. """.strip() ) '') (pkgs.writers.writePython3Bin "test-imap-read" { } '' from imaplib import IMAP4 with IMAP4('localhost') as imap: imap.starttls() status, [caps] = imap.login('bob', 'foobar') assert status == 'OK' imap.select() status, [ref] = imap.search(None, 'ALL') assert status == 'OK' [msgId] = ref.split() status, msg = imap.fetch(msgId, 'BODY[TEXT]') assert status == 'OK' assert msg[0][1].strip() == b'This is a test message.' '') ]; }; testScript = /* python */ '' main.wait_for_unit("stalwart-mail.service") main.wait_for_open_port(587) main.wait_for_open_port(143) </del> <ins> }; </ins> <del> main.succeed("test-smtp-submission") main.succeed("test-imap-read") ''; </del> <ins> testScript = '' start_all() machine.wait_for_unit("stalwart-mail.service") machine.wait_for_open_port(587) machine.wait_for_open_port(143) </ins> <del> meta = { maintainers = with lib.maintainers; [ happysalada pacien ]; }; }) </del> <ins> machine.succeed("test-smtp-submission") machine.succeed("test-imap-read") ''; }; in lib.mapAttrs (_: package: makeStalwartTest { inherit package; }) stalwartPackages </ins>

Discussion:
The new version of stalwart mail (0.7.0), has changed a lot and the module needs a rewrite for a while now, for example: I have forked nixpkgs, to remove the standard settings, to allow me to make a more complex setting. issues I see. No way to disable the default options, in: . WebUI is not currently supported The package imports the entire . <!-- Please @ people who are in the list of the offending package or module. If in doubt, check for whoever last touched something. --Add a :+1: [reaction] to [issues you find important]. [reaction]: [issues you find important]:
If you want to make a contribution, even a small one, im happy to help you get it merged !
I can take a look, as I have written quite extensive configuration for my Stalwart instance. I can check it out to make it available as a NixOS module
That would be amazing ! There is an open pr from the bot for the 0.7 upgrade, you can take over that one or make the update in a new pr. Thank you !
WIP module. I haven't tested it out yet. I will probably do so this evening:
Not yet entirely fixed, module and test need some work to support = 0.7.0
By the way, since migrating to stalwart = 0.7 requires some manual migration in any case, would it be worth setting the default database type to rocksdb instead of sqlite in the module?
In my opinion yes, for the love of Linux or just make it undefined. Do you have a git repo, where I can track your progress and when I have time, give improvements?