From 919412e24e563015985928683e389a6ff2575def Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 17 Aug 2025 02:37:34 +0200 Subject: [PATCH 1/3] matrix-synapse-unwrapped: clean up --- .../ma/matrix-synapse-unwrapped/package.nix | 52 ++++++------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix b/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix index 94689e2570e0..cfd8522dc67d 100644 --- a/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix +++ b/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix @@ -2,8 +2,7 @@ lib, stdenv, fetchFromGitHub, - fetchpatch, - python3, + python3Packages, openssl, libiconv, cargo, @@ -13,10 +12,7 @@ nix-update-script, }: -let - plugins = python3.pkgs.callPackage ./plugins { }; -in -python3.pkgs.buildPythonApplication rec { +python3Packages.buildPythonApplication rec { pname = "matrix-synapse"; version = "1.136.0"; format = "pyproject"; @@ -33,29 +29,13 @@ python3.pkgs.buildPythonApplication rec { hash = "sha256-GX4lVg6aPVlqFgSSGsUg3wi7bne9jVWPTVx8rO5SjL8="; }; - postPatch = '' - # Remove setuptools_rust from runtime dependencies - # https://github.com/element-hq/synapse/blob/v1.69.0/pyproject.toml#L177-L185 - sed -i '/^setuptools_rust =/d' pyproject.toml - - # Remove version pin on build dependencies. Upstream does this on purpose to - # be extra defensive, but we don't want to deal with updating this - sed -i 's/"poetry-core>=\([0-9.]*\),<=[0-9.]*"/"poetry-core>=\1"/' pyproject.toml - sed -i 's/"setuptools_rust>=\([0-9.]*\),<=[0-9.]*"/"setuptools_rust>=\1"/' pyproject.toml - - # Don't force pillow to be 10.0.1 because we already have patched it, and - # we don't use the pillow wheels. - sed -i 's/Pillow = ".*"/Pillow = ">=5.4.0"/' pyproject.toml - - # https://github.com/element-hq/synapse/pull/17878#issuecomment-2575412821 - substituteInPlace tests/storage/databases/main/test_events_worker.py \ - --replace-fail "def test_recovery" "def no_test_recovery" - ''; - - nativeBuildInputs = with python3.pkgs; [ + build-system = with python3Packages; [ poetry-core - rustPlatform.cargoSetupHook setuptools-rust + ]; + + nativeBuildInputs = [ + rustPlatform.cargoSetupHook cargo rustc ]; @@ -67,8 +47,10 @@ python3.pkgs.buildPythonApplication rec { libiconv ]; - propagatedBuildInputs = - with python3.pkgs; + pythonRemoveDeps = [ "setuptools_rust" ]; + + dependencies = + with python3Packages; [ attrs bcrypt @@ -103,7 +85,7 @@ python3.pkgs.buildPythonApplication rec { ] ++ twisted.optional-dependencies.tls; - optional-dependencies = with python3.pkgs; { + optional-dependencies = with python3Packages; { postgres = if isPyPy then [ @@ -143,11 +125,11 @@ python3.pkgs.buildPythonApplication rec { nativeCheckInputs = [ openssl ] - ++ (with python3.pkgs; [ + ++ (with python3Packages; [ mock parameterized ]) - ++ builtins.filter (p: !p.meta.broken) (lib.flatten (lib.attrValues optional-dependencies)); + ++ lib.filter (pkg: !pkg.meta.broken) (lib.flatten (lib.attrValues optional-dependencies)); doCheck = !stdenv.hostPlatform.isDarwin; @@ -164,15 +146,15 @@ python3.pkgs.buildPythonApplication rec { NIX_BUILD_CORES=4 fi - PYTHONPATH=".:$PYTHONPATH" ${python3.interpreter} -m twisted.trial -j $NIX_BUILD_CORES tests + PYTHONPATH=".:$PYTHONPATH" ${python3Packages.python.interpreter} -m twisted.trial -j $NIX_BUILD_CORES tests runHook postCheck ''; passthru = { tests = { inherit (nixosTests) matrix-synapse matrix-synapse-workers; }; - inherit plugins; - python = python3; + plugins = python3Packages.callPackage ./plugins { }; + inherit (python3Packages) python; updateScript = nix-update-script { }; }; From 8d97843ae2c7d7b318ff701259b916e21ca589fd Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 17 Aug 2025 02:58:22 +0200 Subject: [PATCH 2/3] nixos/tests/matrix-synapse: resolve deprecation warning --- nixos/tests/matrix/synapse.nix | 60 ++++++++++++++++------------------ 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/nixos/tests/matrix/synapse.nix b/nixos/tests/matrix/synapse.nix index 1f67f158fd56..7827705ffe21 100644 --- a/nixos/tests/matrix/synapse.nix +++ b/nixos/tests/matrix/synapse.nix @@ -67,7 +67,7 @@ in ... }: let - mailserverIP = nodes.mailserver.config.networking.primaryIPAddress; + mailserverIP = nodes.mailserver.networking.primaryIPAddress; in { services.matrix-synapse = { @@ -169,44 +169,40 @@ in }; # test mail delivery - mailserver = - args: - let - in - { - security.pki.certificateFiles = [ - mailerCerts.ca.cert - ]; + mailserver = args: { + security.pki.certificateFiles = [ + mailerCerts.ca.cert + ]; - networking.firewall.enable = false; + networking.firewall.enable = false; - services.postfix = { - enable = true; - enableSubmission = true; + services.postfix = { + enable = true; + enableSubmission = true; - # blackhole transport - transport = "example.com discard:silently"; + # blackhole transport + transport = "example.com discard:silently"; - settings.main = { - myhostname = "${mailerDomain}"; - # open relay for subnet - mynetworks_style = "subnet"; - debug_peer_level = "10"; - smtpd_relay_restrictions = [ - "permit_mynetworks" - "reject_unauth_destination" - ]; + settings.main = { + myhostname = "${mailerDomain}"; + # open relay for subnet + mynetworks_style = "subnet"; + debug_peer_level = "10"; + smtpd_relay_restrictions = [ + "permit_mynetworks" + "reject_unauth_destination" + ]; - # disable obsolete protocols, something old versions of twisted are still using - smtpd_tls_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3"; - smtpd_tls_mandatory_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3"; - smtpd_tls_chain_files = [ - "${mailerCerts.${mailerDomain}.key}" - "${mailerCerts.${mailerDomain}.cert}" - ]; - }; + # disable obsolete protocols, something old versions of twisted are still using + smtpd_tls_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3"; + smtpd_tls_mandatory_protocols = "TLSv1.3, TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3"; + smtpd_tls_chain_files = [ + "${mailerCerts.${mailerDomain}.key}" + "${mailerCerts.${mailerDomain}.cert}" + ]; }; }; + }; serversqlite = args: { services.matrix-synapse = { From 260fae4daa432b96359b9d6794786278f89de478 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 17 Aug 2025 15:09:13 +0200 Subject: [PATCH 3/3] matrix-synapse-unwrapped: restrict to linux This is the only platform we and upstream test for. --- pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix b/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix index cfd8522dc67d..7b29a8490732 100644 --- a/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix +++ b/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix @@ -165,5 +165,6 @@ python3Packages.buildPythonApplication rec { license = lib.licenses.agpl3Plus; maintainers = with lib.maintainers; [ sumnerevans ]; teams = [ lib.teams.matrix ]; + platforms = lib.platforms.linux; }; }