15 plugins = python3.pkgs.callPackage ./plugins { };
16 tools = callPackage ./tools { };
18 python3.pkgs.buildPythonApplication rec {
19 pname = "matrix-synapse";
23 src = fetchFromGitHub {
27 hash = "sha256-CgoJJK2pqkHU8X6oisY19uN6zyjGL8W3irTsraFOYQM=";
30 cargoDeps = rustPlatform.fetchCargoTarball {
32 name = "${pname}-${version}";
33 hash = "sha256-uKyy2m3bvo6U++Qx6t7maeIp84QfMzslPGV1so4ZT3U=";
37 # Remove setuptools_rust from runtime dependencies
38 # https://github.com/element-hq/synapse/blob/v1.69.0/pyproject.toml#L177-L185
39 sed -i '/^setuptools_rust =/d' pyproject.toml
41 # Remove version pin on build dependencies. Upstream does this on purpose to
42 # be extra defensive, but we don't want to deal with updating this
43 sed -i 's/"poetry-core>=\([0-9.]*\),<=[0-9.]*"/"poetry-core>=\1"/' pyproject.toml
44 sed -i 's/"setuptools_rust>=\([0-9.]*\),<=[0-9.]*"/"setuptools_rust>=\1"/' pyproject.toml
46 # Don't force pillow to be 10.0.1 because we already have patched it, and
47 # we don't use the pillow wheels.
48 sed -i 's/Pillow = ".*"/Pillow = ">=5.4.0"/' pyproject.toml
51 nativeBuildInputs = with python3.pkgs; [
53 rustPlatform.cargoSetupHook
61 ] ++ lib.optionals stdenv.isDarwin [
65 propagatedBuildInputs = with python3.pkgs; [
97 ++ twisted.optional-dependencies.tls;
99 passthru.optional-dependencies = with python3.pkgs; {
100 postgres = if isPyPy then [
135 nativeCheckInputs = [
137 ] ++ (with python3.pkgs; [
141 ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
143 doCheck = !stdenv.isDarwin;
148 # remove src module, so tests use the installed module instead
151 # high parallelisem makes test suite unstable
152 # upstream uses 2 cores but 4 seems to be also stable
153 # https://github.com/element-hq/synapse/blob/develop/.github/workflows/latest_deps.yml#L103
154 if (( $NIX_BUILD_CORES > 4)); then
158 PYTHONPATH=".:$PYTHONPATH" ${python3.interpreter} -m twisted.trial -j $NIX_BUILD_CORES tests
164 tests = { inherit (nixosTests) matrix-synapse matrix-synapse-workers; };
165 inherit plugins tools;
170 homepage = "https://matrix.org";
171 changelog = "https://github.com/element-hq/synapse/releases/tag/v${version}";
172 description = "Matrix reference homeserver";
173 license = licenses.agpl3Plus;
174 maintainers = teams.matrix.members;