From e7db3c950fb2902fc31ef4fd7573993713dffc80 Mon Sep 17 00:00:00 2001 From: Ethan Carter Edwards Date: Sun, 20 Jul 2025 23:31:37 -0400 Subject: [PATCH] nixos/tests/stalwart: split config into separate file NGIpkgs (ngi-nix) is interested in reusing some of the stalwart test's config. Split it into a separate file. Signed-off-by: Ethan Carter Edwards --- nixos/tests/all-tests.nix | 2 +- nixos/tests/stalwart/stalwart-mail-config.nix | 81 +++++++++++++++++++ nixos/tests/{ => stalwart}/stalwart-mail.nix | 78 +----------------- 3 files changed, 86 insertions(+), 75 deletions(-) create mode 100644 nixos/tests/stalwart/stalwart-mail-config.nix rename nixos/tests/{ => stalwart}/stalwart-mail.nix (53%) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 166dbbdca2e5..fd7caf0bacf6 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1331,7 +1331,7 @@ in ssh-audit = runTest ./ssh-audit.nix; sssd = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./sssd.nix { }; sssd-ldap = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./sssd-ldap.nix { }; - stalwart-mail = runTest ./stalwart-mail.nix; + stalwart-mail = runTest ./stalwart/stalwart-mail.nix; stargazer = runTest ./web-servers/stargazer.nix; starship = runTest ./starship.nix; stash = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./stash.nix { }; diff --git a/nixos/tests/stalwart/stalwart-mail-config.nix b/nixos/tests/stalwart/stalwart-mail-config.nix new file mode 100644 index 000000000000..800090ab5949 --- /dev/null +++ b/nixos/tests/stalwart/stalwart-mail-config.nix @@ -0,0 +1,81 @@ +{ pkgs, lib, ... }: + +let + certs = import ../common/acme/server/snakeoil-certs.nix; + domain = certs.domain; +in +{ + 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"; + enable = true; + implicit = false; + }; + + server.listener = { + "smtp-submission" = { + bind = [ "[::]:587" ]; + protocol = "smtp"; + }; + + "imap" = { + bind = [ "[::]:143" ]; + protocol = "imap"; + }; + + "http" = { + bind = [ "[::]:80" ]; + protocol = "http"; + }; + }; + + session.auth.mechanisms = "[plain]"; + session.auth.directory = "'in-memory'"; + storage.directory = "in-memory"; + + storage.data = "rocksdb"; + storage.fts = "rocksdb"; + storage.blob = "rocksdb"; + storage.lookup = "rocksdb"; + + session.rcpt.directory = "'in-memory'"; + queue.outbound.next-hop = "'local'"; + + store."rocksdb" = { + type = "rocksdb"; + path = "/var/lib/stalwart-mail/data"; + compression = "lz4"; + }; + + directory."in-memory" = { + type = "memory"; + principals = [ + { + class = "individual"; + name = "alice"; + secret = "foobar"; + email = [ "alice@${domain}" ]; + } + { + class = "individual"; + name = "bob"; + secret = "foobar"; + email = [ "bob@${domain}" ]; + } + ]; + }; + }; + }; + +} diff --git a/nixos/tests/stalwart-mail.nix b/nixos/tests/stalwart/stalwart-mail.nix similarity index 53% rename from nixos/tests/stalwart-mail.nix rename to nixos/tests/stalwart/stalwart-mail.nix index 4eef33e63e81..f7b733f7f658 100644 --- a/nixos/tests/stalwart-mail.nix +++ b/nixos/tests/stalwart/stalwart-mail.nix @@ -3,9 +3,8 @@ # - serve this message through IMAP. let - certs = import ./common/acme/server/snakeoil-certs.nix; + certs = import ../common/acme/server/snakeoil-certs.nix; domain = certs.domain; - in { lib, ... }: { @@ -14,78 +13,9 @@ in 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"; - enable = true; - implicit = false; - }; - - server.listener = { - "smtp-submission" = { - bind = [ "[::]:587" ]; - protocol = "smtp"; - }; - - "imap" = { - bind = [ "[::]:143" ]; - protocol = "imap"; - }; - - "http" = { - bind = [ "[::]:80" ]; - protocol = "http"; - }; - }; - - session.auth.mechanisms = "[plain]"; - session.auth.directory = "'in-memory'"; - storage.directory = "in-memory"; - - storage.data = "rocksdb"; - storage.fts = "rocksdb"; - storage.blob = "rocksdb"; - storage.lookup = "rocksdb"; - - session.rcpt.directory = "'in-memory'"; - queue.outbound.next-hop = "'local'"; - - store."rocksdb" = { - type = "rocksdb"; - path = "/var/lib/stalwart-mail/data"; - compression = "lz4"; - }; - - directory."in-memory" = { - type = "memory"; - principals = [ - { - class = "individual"; - name = "alice"; - secret = "foobar"; - email = [ "alice@${domain}" ]; - } - { - class = "individual"; - name = "bob"; - secret = "foobar"; - email = [ "bob@${domain}" ]; - } - ]; - }; - }; - }; + imports = [ + ./stalwart-mail-config.nix + ]; environment.systemPackages = [ (pkgs.writers.writePython3Bin "test-smtp-submission" { } ''