2023-08-22 20:05:09 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, python3
|
|
|
|
, openssl
|
|
|
|
, cargo
|
|
|
|
, rustPlatform
|
|
|
|
, rustc
|
2023-02-02 18:25:31 +00:00
|
|
|
, nixosTests
|
2020-12-25 13:55:36 +00:00
|
|
|
, callPackage
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
let
|
2021-12-06 16:07:01 +00:00
|
|
|
plugins = python3.pkgs.callPackage ./plugins { };
|
2020-12-25 13:55:36 +00:00
|
|
|
tools = callPackage ./tools { };
|
2020-06-18 07:06:33 +00:00
|
|
|
in
|
2023-08-22 20:05:09 +00:00
|
|
|
python3.pkgs.buildPythonApplication rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "matrix-synapse";
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "1.95.1";
|
2022-09-30 11:47:45 +00:00
|
|
|
format = "pyproject";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "matrix-org";
|
|
|
|
repo = "synapse";
|
|
|
|
rev = "v${version}";
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = "sha256-5RyJCMYsf6p9rd1ATEHa+FMV6vv3ULbcx7PXxMSUGSU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
name = "${pname}-${version}";
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = "sha256-gNjpML+j9ABv24WrAiJI5hoEoIqcVPL2I4V/W+sWFSg=";
|
2022-09-30 11:47:45 +00:00
|
|
|
};
|
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Remove setuptools_rust from runtime dependencies
|
|
|
|
# https://github.com/matrix-org/synapse/blob/v1.69.0/pyproject.toml#L177-L185
|
|
|
|
sed -i '/^setuptools_rust =/d' pyproject.toml
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
# 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
|
2022-10-30 15:09:59 +00:00
|
|
|
'';
|
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
nativeBuildInputs = with python3.pkgs; [
|
2022-09-30 11:47:45 +00:00
|
|
|
poetry-core
|
|
|
|
rustPlatform.cargoSetupHook
|
|
|
|
setuptools-rust
|
|
|
|
cargo
|
|
|
|
rustc
|
2023-05-24 13:37:59 +00:00
|
|
|
];
|
2022-09-30 11:47:45 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
buildInputs = [
|
|
|
|
openssl
|
|
|
|
];
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
propagatedBuildInputs = with python3.pkgs; [
|
|
|
|
attrs
|
2020-04-24 23:36:52 +00:00
|
|
|
bcrypt
|
|
|
|
bleach
|
|
|
|
canonicaljson
|
2023-08-22 20:05:09 +00:00
|
|
|
cryptography
|
2021-06-04 09:07:49 +00:00
|
|
|
ijson
|
2023-04-29 16:46:19 +00:00
|
|
|
immutabledict
|
2020-04-24 23:36:52 +00:00
|
|
|
jinja2
|
|
|
|
jsonschema
|
2022-01-19 23:45:15 +00:00
|
|
|
matrix-common
|
2020-04-24 23:36:52 +00:00
|
|
|
msgpack
|
|
|
|
netaddr
|
2023-08-22 20:05:09 +00:00
|
|
|
packaging
|
2020-04-24 23:36:52 +00:00
|
|
|
phonenumbers
|
|
|
|
pillow
|
2021-08-27 14:25:00 +00:00
|
|
|
prometheus-client
|
2020-04-24 23:36:52 +00:00
|
|
|
pyasn1
|
2023-08-22 20:05:09 +00:00
|
|
|
pyasn1-modules
|
2022-09-09 14:08:57 +00:00
|
|
|
pydantic
|
2020-04-24 23:36:52 +00:00
|
|
|
pymacaroons
|
|
|
|
pyopenssl
|
|
|
|
pyyaml
|
2023-08-22 20:05:09 +00:00
|
|
|
service-identity
|
2020-04-24 23:36:52 +00:00
|
|
|
signedjson
|
|
|
|
sortedcontainers
|
|
|
|
treq
|
|
|
|
twisted
|
|
|
|
typing-extensions
|
2021-06-04 09:07:49 +00:00
|
|
|
unpaddedbase64
|
2023-08-22 20:05:09 +00:00
|
|
|
]
|
|
|
|
++ twisted.optional-dependencies.tls;
|
|
|
|
|
|
|
|
passthru.optional-dependencies = with python3.pkgs; {
|
|
|
|
postgres = if isPyPy then [
|
|
|
|
psycopg2cffi
|
|
|
|
] else [
|
|
|
|
psycopg2
|
|
|
|
];
|
|
|
|
saml2 = [
|
|
|
|
pysaml2
|
|
|
|
];
|
|
|
|
oidc = [
|
|
|
|
authlib
|
|
|
|
];
|
|
|
|
systemd = [
|
|
|
|
systemd
|
|
|
|
];
|
|
|
|
url-preview = [
|
|
|
|
lxml
|
|
|
|
];
|
|
|
|
sentry = [
|
|
|
|
sentry-sdk
|
|
|
|
];
|
|
|
|
jwt = [
|
|
|
|
authlib
|
|
|
|
];
|
|
|
|
redis = [
|
|
|
|
hiredis
|
|
|
|
txredisapi
|
|
|
|
];
|
|
|
|
cache-memory = [
|
|
|
|
pympler
|
|
|
|
];
|
|
|
|
user-search = [
|
|
|
|
pyicu
|
|
|
|
];
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
openssl
|
|
|
|
] ++ (with python3.pkgs; [
|
|
|
|
mock
|
|
|
|
parameterized
|
|
|
|
])
|
|
|
|
++ lib.flatten (lib.attrValues passthru.optional-dependencies);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
doCheck = !stdenv.isDarwin;
|
|
|
|
|
|
|
|
checkPhase = ''
|
2022-09-30 11:47:45 +00:00
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
# remove src module, so tests use the installed module instead
|
|
|
|
rm -rf ./synapse
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
# high parallelisem makes test suite unstable
|
|
|
|
# upstream uses 2 cores but 4 seems to be also stable
|
|
|
|
# https://github.com/matrix-org/synapse/blob/develop/.github/workflows/latest_deps.yml#L103
|
|
|
|
if (( $NIX_BUILD_CORES > 4)); then
|
|
|
|
NIX_BUILD_CORES=4
|
|
|
|
fi
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
PYTHONPATH=".:$PYTHONPATH" ${python3.interpreter} -m twisted.trial -j $NIX_BUILD_CORES tests
|
2022-09-30 11:47:45 +00:00
|
|
|
|
|
|
|
runHook postCheck
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
passthru = {
|
2023-10-09 19:29:22 +00:00
|
|
|
tests = { inherit (nixosTests) matrix-synapse matrix-synapse-workers; };
|
2023-07-15 17:15:38 +00:00
|
|
|
inherit plugins tools;
|
|
|
|
python = python3;
|
|
|
|
};
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://matrix.org";
|
2023-08-22 20:05:09 +00:00
|
|
|
changelog = "https://github.com/matrix-org/synapse/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Matrix reference homeserver";
|
|
|
|
license = licenses.asl20;
|
2020-06-18 07:06:33 +00:00
|
|
|
maintainers = teams.matrix.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|