From 5f2ded90f5ca0609697a155505e4ac9a2a25b694 Mon Sep 17 00:00:00 2001 From: Gonne Date: Mon, 24 Feb 2025 22:46:42 +0100 Subject: [PATCH] Enable redirects to sender using less own repositories --- flake-module.nix | 28 ++++++++++++++-------------- sieve-rs.patch | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 sieve-rs.patch diff --git a/flake-module.nix b/flake-module.nix index a5734a4..6154426 100644 --- a/flake-module.nix +++ b/flake-module.nix @@ -59,14 +59,16 @@ config.permittedInsecurePackages = ["jitsi-meet-1.0.8043"]; overlays = [ - (final: prev: { + (_: prev: { alias-to-sieve = inputs.alias-to-sieve.packages.x86_64-linux.default; # add custom package to convert alias files to sieve scripts on the stalwart machine - stalwart-mail = assert lib.assertMsg (prev.stalwart-mail.version == "0.11.6-unstable-2025-02-04") "Copy the Cargo.lock file from upstream and reintroduce the patch to sieve-rs, then update this assert statement."; - /* - prev.stalwart-mail.overrideAttrs ( - finalAttrs: prevAttrs: - prevAttrs - */ + stalwart-mail = assert lib.assertMsg (prev.stalwart-mail.version == "0.11.6-unstable-2025-02-04") '' + 1. If the bug https://github.com/stalwartlabs/sieve/issues/11 is resolved to our satisfaction, try to remove this overlay. + 2. Check whether sieve-rs recieved new updates that our patch needs to be rebased upon. + 3. Check whether the sieve-rs patch below that exchanges the dependency needs updates. + 4. Then update the version comparison in this assert statement. + 5. Update the `cargoHash` by setting it to `lib.fakeHash` and then inserting the result. + 6. Check if we can get rid of alias-to-sieve when stalwart-mail has a builtin alias feature. + ''; prev.stalwart-mail.override ( let rp = pkgs.rustPlatform; @@ -78,13 +80,11 @@ rp.buildRustPackage ( args // rec { - src = final.fetchFromGitea { - domain = "gitea.mathebau.de"; - owner = "gonne"; - repo = "stalwart-mail"; - rev = "549b7055f6419079bf0b0ddab5367f6e6834d265"; # Depend on sieve-rs without loop prevention - hash = "sha256-6+EyQC9hIDbmf0VGhU4XzNxtw/OgdNSOkm4dTClrowM="; - }; + cargoPatches = [ + # Let stalwart-mail depend on our own version of the sieve crate that does not have some “loop prevention” that disables redirects to the original sender. + # We want to redirect to sender if we simulate alias files and not doing so barely prevents loops in my opinion. + ./sieve-rs.patch + ]; cargoHash = "sha256-fdOU2W/EtkBk+1VmNMkFZTGbwBTQQRelrheVFhiUqlg="; } ); diff --git a/sieve-rs.patch b/sieve-rs.patch new file mode 100644 index 0000000..697a1f3 --- /dev/null +++ b/sieve-rs.patch @@ -0,0 +1,27 @@ +diff --git a/Cargo.lock b/Cargo.lock +index be36759b..b4316639 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -6404,8 +6404,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] + name = "sieve-rs" + version = "0.6.0" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "15ac54053752c25a0e545dd1953de716abcc80b12cfe0b6c2f2c1c73759d4f45" ++source = "git+https://gitea.mathebau.de/Gonne/sieve-rs.git#71324550504c0f84fe3e814d05cbe22f90a3b228" + dependencies = [ + "ahash 0.8.11", + "bincode", +diff --git a/Cargo.toml b/Cargo.toml +index f055474f..2b64c9ac 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -63,3 +63,7 @@ incremental = false + debug-assertions = false + overflow-checks = false + rpath = false ++ ++ ++[patch.crates-io] ++sieve-rs = { git = 'https://gitea.mathebau.de/Gonne/sieve-rs.git' } +