about summary refs log tree commit diff stats
path: root/pkgs/by-name/st/stalwart-mail-free/package.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-04 19:21:22 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-09 13:44:23 +0100
commit80fab76532b5b159cf0c9c910387b1c09907be30 (patch)
treea44b2662847ae6c712ef84e54f6c208444252eb6 /pkgs/by-name/st/stalwart-mail-free/package.nix
parentmodules/dns/dns/types/records/MTA-STS.nix: Init (diff)
downloadnixos-server-80fab76532b5b159cf0c9c910387b1c09907be30.zip
pkgs/stalwart-mail-free: Also patch to use the platform CA store
This is needed for the test.

The general changes are caused by the requirement to update the
`chargoHash`, which currently only works with this counter intuitive
attribute overriding.
Diffstat (limited to 'pkgs/by-name/st/stalwart-mail-free/package.nix')
-rw-r--r--pkgs/by-name/st/stalwart-mail-free/package.nix103
1 files changed, 66 insertions, 37 deletions
diff --git a/pkgs/by-name/st/stalwart-mail-free/package.nix b/pkgs/by-name/st/stalwart-mail-free/package.nix
index 64fb2d6..6daa2f8 100644
--- a/pkgs/by-name/st/stalwart-mail-free/package.nix
+++ b/pkgs/by-name/st/stalwart-mail-free/package.nix
@@ -4,41 +4,70 @@
   nixLib,
 }: let
   spamfilter = callPackage ./spam-filter.nix {};
+
+  mail-send = callPackage ./mail-send.nix {};
+
+  # Need to use the newer `rustPlatform`
+  inherit (pkgsUnstable) rustPlatform;
 in
-  pkgsUnstable.stalwart-mail.overrideAttrs (final: prev: {
-    passthru = nixLib.warnMerge (prev.passthru or {}) {
-      inherit spamfilter;
-    } "stalwart-mail passthru";
-
-    checkFlags =
-      (prev.checkFlags or [])
-      ++ [
-        # This started to fail?
-        # TODO(@bpeetz): Find out why. <2025-02-08>
-        "--skip=smtp::outbound::lmtp::lmtp_delivery"
-      ];
-
-    # `stalwart-mail` does enable their `enterprise` feature per default.
-    # We want a AGPL only build (i.e., without unfree dependencies), therefore disable the
-    # `enterprise` feature here.
-    # We cannot use the `buildFeatures` attribute because it does not actually change the
-    # correct features. As such we simply patch the correct `Cargo.toml` file.
-    patches =
-      (prev.patches or [])
-      ++ [
-        ./patches/build-crates-main-Cargo.toml-Activate-appropriate-de.patch
-        ./patches/fix-crates-directory-Guard-all-enterprise-only-featu.patch
-      ];
-
-    # Check that the enterprise feature is really disabled.
-    postCheck =
-      (prev.postCheck or "")
-      +
-      # bash
-      ''
-        if grep "enterprise" ./target/*/release/stalwart-mail.d; then
-          echo "ERROR: Proprietary 'enterprise' feature active."
-          exit 1
-        fi
-      '';
-  })
+  pkgsUnstable.stalwart-mail.override {
+    rustPlatform =
+      rustPlatform
+      // {
+        buildRustPackage = prev:
+          rustPlatform.buildRustPackage (
+            prev
+            // {
+              pname = "stalwart-mail-free";
+              passthru = nixLib.warnMerge (prev.passthru or {}) {
+                inherit spamfilter;
+              } "stalwart-mail passthru";
+
+              useFetchCargoVendor = true;
+              cargoHash = "sha256-qZG67esSpdyfNswmgP6NHlbIon05V39oTfbQloXkwSM=";
+
+              buildNoDefaultFeatures = true;
+              buildFeatures = [
+                "rocks"
+                "redis"
+              ];
+
+              postUnpack =
+                (prev.postUnpack or "")
+                + ''
+                  cp --recursive "${mail-send}" ./source/crates/mail-send
+                  chmod -R +w "./source/crates/mail-send"
+                '';
+
+              cargoPatches =
+                (prev.cargoPatches or [])
+                ++ [
+                  # `stalwart-mail` does enable their `enterprise` feature per default.
+                  # We want a AGPL only build (i.e., without unfree dependencies), therefore disable the
+                  # `enterprise` feature here.
+                  # We cannot use the `buildFeatures` attribute because it does not actually change the
+                  # correct features. As such we simply patch the correct `Cargo.toml` file.
+                  ./patches/crates-main-Cargo.toml-Use-libre-features.patch
+
+                  # `stalwart-mail` uses their bundled store, which makes it impossible to use our
+                  # own CA certificate (e.g., for tests). Thus use a native version.
+                  ./patches/crates-Use-the-platform-CA-bundle-instead-of-the-bun.patch
+                ];
+
+              # Check that the enterprise feature is really disabled.
+              postCheck =
+                (prev.postCheck or "")
+                +
+                # bash
+                ''
+                  if grep "enterprise" ./target/*/release/stalwart-mail.d; then
+                    echo "ERROR: Proprietary 'enterprise' feature active."
+                    exit 1
+                  fi
+                '';
+
+              meta.mainProgram = prev.meta.mainProgram or "stalwart-mail";
+            }
+          );
+      };
+  }