From c7cc3739240e11c983df6b50ba3821880766b18d Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 24 May 2024 12:12:59 +0200 Subject: [PATCH 1/7] stalwart-mail_0_6: drop --- pkgs/top-level/all-packages.nix | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8126fabe5d66..9c68db551d2d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -26586,23 +26586,6 @@ with pkgs; thttpd = callPackage ../servers/http/thttpd { }; - stalwart-mail_0_6 = (stalwart-mail.override { rocksdb_8_11 = rocksdb_8_3; }).overrideAttrs (old: rec { - pname = "stalwart-mail_0_6"; - version = "0.6.0"; - src = fetchFromGitHub { - owner = "stalwartlabs"; - repo = "mail-server"; - rev = "v${version}"; - hash = "sha256-OHwUWSUW6ovLQTxnuUrolQGhxbhp4YqKSH+ZTpe2WXc="; - fetchSubmodules = true; - }; - cargoDeps = old.cargoDeps.overrideAttrs (_: { - inherit src; - name = "${pname}-${version}-vendor.tar.gz"; - outputHash = "sha256-mW3OXQj6DcIMO1YlTG3G+a1ORRcuvp5/h7BU+b4QbnE="; - }); - }); - static-web-server = callPackage ../servers/static-web-server { }; stone = callPackage ../servers/stone { }; From 2323925c24c578fc239c0cc0dce06a6a1d63cc5d Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 24 May 2024 12:13:16 +0200 Subject: [PATCH 2/7] stalwart-mail: add onny as maintainer --- pkgs/by-name/st/stalwart-mail/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/st/stalwart-mail/package.nix b/pkgs/by-name/st/stalwart-mail/package.nix index d021afe01f64..68e0d97bebb5 100644 --- a/pkgs/by-name/st/stalwart-mail/package.nix +++ b/pkgs/by-name/st/stalwart-mail/package.nix @@ -75,6 +75,6 @@ rustPlatform.buildRustPackage { homepage = "https://github.com/stalwartlabs/mail-server"; changelog = "https://github.com/stalwartlabs/mail-server/blob/${version}/CHANGELOG"; license = licenses.agpl3Only; - maintainers = with maintainers; [ happysalada ]; + maintainers = with maintainers; [ happysalada onny ]; }; } From 3d6a20f3807ea5d5d2b6bf03c7561f0d142df02a Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 24 May 2024 12:15:50 +0200 Subject: [PATCH 3/7] nixos/stalwart-mail: drop legacy package --- nixos/modules/services/mail/stalwart-mail.nix | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/nixos/modules/services/mail/stalwart-mail.nix b/nixos/modules/services/mail/stalwart-mail.nix index 06b48c86907c..0a9e4daf29cc 100644 --- a/nixos/modules/services/mail/stalwart-mail.nix +++ b/nixos/modules/services/mail/stalwart-mail.nix @@ -7,28 +7,12 @@ let configFormat = pkgs.formats.toml { }; configFile = configFormat.generate "stalwart-mail.toml" cfg.settings; dataDir = "/var/lib/stalwart-mail"; - stalwartAtLeast = versionAtLeast cfg.package.version; in { options.services.stalwart-mail = { enable = mkEnableOption "the Stalwart all-in-one email server"; - package = mkOption { - type = types.package; - description = '' - Which package to use for the Stalwart mail server. - - ::: {.note} - Upgrading from version 0.6.0 to version 0.7.0 or higher requires manual - intervention. See - for upgrade instructions. - ::: - ''; - default = pkgs.stalwart-mail_0_6; - defaultText = lib.literalExpression "pkgs.stalwart-mail_0_6"; - example = lib.literalExpression "pkgs.stalwart-mail"; - relatedPackages = [ "stalwart-mail_0_6" "stalwart-mail" ]; - }; + package = mkPackageOption pkgs "stalwart-mail" { }; settings = mkOption { inherit (configFormat) type; @@ -44,17 +28,6 @@ in { config = mkIf cfg.enable { - warnings = lib.optionals (!stalwartAtLeast "0.7.0") [ - '' - Versions of stalwart-mail < 0.7.0 will get deprecated in NixOS 24.11. - Please set services.stalwart-mail.package to pkgs.stalwart-mail to - upgrade to the latest version. - Please note that upgrading to version >= 0.7 requires manual - intervention, see - for upgrade instructions. - '' - ]; - # Default config: all local services.stalwart-mail.settings = { global.tracing.method = mkDefault "stdout"; From dfe479c64e90019cc22b7c9dcd3f77633c1008fd Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 24 May 2024 12:20:38 +0200 Subject: [PATCH 4/7] nixos/tests/stalwart-mail: drop legacy package --- nixos/tests/stalwart-mail.nix | 227 +++++++++++++++------------------- 1 file changed, 100 insertions(+), 127 deletions(-) diff --git a/nixos/tests/stalwart-mail.nix b/nixos/tests/stalwart-mail.nix index 4075b32e2c1f..d223450d5f28 100644 --- a/nixos/tests/stalwart-mail.nix +++ b/nixos/tests/stalwart-mail.nix @@ -1,147 +1,120 @@ # Rudimentary test checking that the Stalwart email server can: # - receive some message through SMTP submission, then # - serve this message through IMAP. -{ - system ? builtins.currentSystem, - config ? { }, - pkgs ? import ../../.. { inherit system config; }, - lib ? pkgs.lib, -}: let certs = import ./common/acme/server/snakeoil-certs.nix; domain = certs.domain; - 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, ... }: { +in import ./make-test-python.nix ({ lib, ... }: { + name = "stalwart-mail"; - security.pki.certificateFiles = [ certs.ca.cert ]; + nodes.main = { pkgs, ... }: { + security.pki.certificateFiles = [ certs.ca.cert ]; - services.stalwart-mail = { + 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"; enable = true; - inherit package; - settings = { - server.hostname = domain; + implicit = false; + }; - # 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.listener = { + "smtp-submission" = { + bind = [ "[::]:587" ]; + protocol = "smtp"; + }; - 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}" ]; - } - ]; - }; + "imap" = { + bind = [ "[::]:143" ]; + protocol = "imap"; }; }; - environment.systemPackages = [ - (pkgs.writers.writePython3Bin "test-smtp-submission" { } '' - from smtplib import SMTP + session.auth.mechanisms = "[plain]"; + session.auth.directory = "'in-memory'"; + storage.directory = "in-memory"; - 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.' - '') - ]; + session.rcpt.directory = "'in-memory'"; + queue.outbound.next-hop = "'local'"; + directory."in-memory" = { + type = "memory"; + principals = [ + { + class = "individual"; + name = "alice"; + secret = "foobar"; + email = [ "alice@${domain}" ]; + } + { + class = "individual"; + name = "bob"; + secret = "foobar"; + email = [ "bob@${domain}" ]; + } + ]; + }; }; - - testScript = '' - start_all() - machine.wait_for_unit("stalwart-mail.service") - machine.wait_for_open_port(587) - machine.wait_for_open_port(143) - - machine.succeed("test-smtp-submission") - machine.succeed("test-imap-read") - ''; }; -in -lib.mapAttrs (_: package: makeStalwartTest { inherit package; }) stalwartPackages + + 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) + + main.succeed("test-smtp-submission") + main.succeed("test-imap-read") + ''; + + meta = { + maintainers = with lib.maintainers; [ happysalada pacien ]; + }; +}) From 3c80361f9a43bc94561156b10002ea18f7856f4d Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 24 May 2024 12:25:33 +0200 Subject: [PATCH 5/7] nixos/stalwart-mail: add release notes --- nixos/doc/manual/release-notes/rl-2411.section.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 2277308d6ba2..343c1fc5933d 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -16,6 +16,11 @@ nvimpager settings: user commands in `-c` and `--cmd` now override the respective default settings because they are executed later. +- Legacy package `stalwart-mail_0_6` was dropped, please note the + [manual upgrade process](https://github.com/stalwartlabs/mail-server/blob/main/UPGRADING.md) + before changing the package to `pkgs.stalwart-mail` in + [`services.stalwart-mail.package`](#opt-services.stalwart-mail.package). + ## Other Notable Changes {#sec-release-24.11-notable-changes} - Create the first release note entry in this section! From 2d53258c2e973b41744d5c087acbe7e82c481b65 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 24 May 2024 12:25:54 +0200 Subject: [PATCH 6/7] nixos/tests/stalwart-mail: add onny as maintainer --- nixos/tests/stalwart-mail.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/tests/stalwart-mail.nix b/nixos/tests/stalwart-mail.nix index d223450d5f28..173b4fce4ad5 100644 --- a/nixos/tests/stalwart-mail.nix +++ b/nixos/tests/stalwart-mail.nix @@ -115,6 +115,6 @@ in import ./make-test-python.nix ({ lib, ... }: { ''; meta = { - maintainers = with lib.maintainers; [ happysalada pacien ]; + maintainers = with lib.maintainers; [ happysalada pacien onny ]; }; }) From 50388b71cc7c244b7a7dce326ba05170ad7b6acc Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 24 May 2024 12:26:13 +0200 Subject: [PATCH 7/7] nixos/stalwart-mail: add onny as maintainer --- nixos/modules/services/mail/stalwart-mail.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/mail/stalwart-mail.nix b/nixos/modules/services/mail/stalwart-mail.nix index 0a9e4daf29cc..68606698e59f 100644 --- a/nixos/modules/services/mail/stalwart-mail.nix +++ b/nixos/modules/services/mail/stalwart-mail.nix @@ -111,6 +111,6 @@ in { }; meta = { - maintainers = with maintainers; [ happysalada pacien ]; + maintainers = with maintainers; [ happysalada pacien onny ]; }; }