diff options
Diffstat (limited to 'pkgs/by-name/st/stalwart-mail-free/package.nix')
-rw-r--r-- | pkgs/by-name/st/stalwart-mail-free/package.nix | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/pkgs/by-name/st/stalwart-mail-free/package.nix b/pkgs/by-name/st/stalwart-mail-free/package.nix new file mode 100644 index 0000000..bb2c1db --- /dev/null +++ b/pkgs/by-name/st/stalwart-mail-free/package.nix @@ -0,0 +1,77 @@ +{ + pkgsUnstable, + callPackage, + 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.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-Qg01QXP/ImRCUw3aXcZbnM1hysHUwozCdQ7LecjUa0o="; + + # The tests should check if this works. + # And this shaves of around 50% of the build time. + doCheck = false; + + 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"; + } + ); + }; + } |