2023-03-15 12:12:37 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2024-03-11 15:42:20 +00:00
|
|
|
, fetchPypi
|
2023-03-15 12:12:37 +00:00
|
|
|
, python3
|
|
|
|
, openssl
|
2023-11-15 17:45:16 +00:00
|
|
|
, libiconv
|
2023-03-15 12:12:37 +00:00
|
|
|
, cargo
|
|
|
|
, rustPlatform
|
|
|
|
, rustc
|
2022-09-21 07:04:52 +00:00
|
|
|
, nixosTests
|
2020-12-08 03:10:09 +00:00
|
|
|
, callPackage
|
2018-11-01 16:48:40 +00:00
|
|
|
}:
|
2018-10-19 04:34:22 +00:00
|
|
|
|
2021-09-07 15:57:29 +00:00
|
|
|
let
|
2024-03-11 15:42:20 +00:00
|
|
|
python = python3.override {
|
|
|
|
packageOverrides = self: super: {
|
|
|
|
netaddr = super.netaddr.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "1.0.0";
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
pname = "netaddr";
|
|
|
|
inherit version;
|
|
|
|
hash = "sha256-6wRrVTVOelv4AcBJAq6SO9aZGQJC2JsJnolvmycktNM=";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
plugins = python.pkgs.callPackage ./plugins { };
|
2020-12-08 03:10:09 +00:00
|
|
|
tools = callPackage ./tools { };
|
2019-10-03 13:59:06 +00:00
|
|
|
in
|
2024-03-11 15:42:20 +00:00
|
|
|
python.pkgs.buildPythonApplication rec {
|
2018-10-19 04:34:22 +00:00
|
|
|
pname = "matrix-synapse";
|
2024-04-30 14:25:37 +00:00
|
|
|
version = "1.106.0";
|
2022-09-27 15:26:53 +00:00
|
|
|
format = "pyproject";
|
2016-01-08 14:12:00 +00:00
|
|
|
|
2022-10-18 16:42:42 +00:00
|
|
|
src = fetchFromGitHub {
|
2023-12-13 22:48:09 +00:00
|
|
|
owner = "element-hq";
|
2022-10-18 16:42:42 +00:00
|
|
|
repo = "synapse";
|
|
|
|
rev = "v${version}";
|
2024-04-30 14:25:37 +00:00
|
|
|
hash = "sha256-FnWYfFlzl6+K5dLhJ+mdphC6E6cA+HewGTUXakRHKEo=";
|
2016-01-08 14:12:00 +00:00
|
|
|
};
|
|
|
|
|
2022-09-27 15:26:53 +00:00
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
name = "${pname}-${version}";
|
2024-04-30 14:25:37 +00:00
|
|
|
hash = "sha256-7X0lXiD+7irex8A3Tnfq65P6BinMje4Bc1MuCI3dSyg=";
|
2022-09-27 15:26:53 +00:00
|
|
|
};
|
|
|
|
|
2022-10-21 06:28:09 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Remove setuptools_rust from runtime dependencies
|
2023-12-13 22:48:09 +00:00
|
|
|
# https://github.com/element-hq/synapse/blob/v1.69.0/pyproject.toml#L177-L185
|
2022-10-21 06:28:09 +00:00
|
|
|
sed -i '/^setuptools_rust =/d' pyproject.toml
|
2023-08-22 04:50:50 +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
|
2023-09-26 16:44:06 +00:00
|
|
|
|
|
|
|
# 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-21 06:28:09 +00:00
|
|
|
'';
|
|
|
|
|
2024-03-11 15:42:20 +00:00
|
|
|
nativeBuildInputs = with python.pkgs; [
|
2022-09-27 15:26:53 +00:00
|
|
|
poetry-core
|
|
|
|
rustPlatform.cargoSetupHook
|
|
|
|
setuptools-rust
|
|
|
|
cargo
|
|
|
|
rustc
|
2023-05-12 14:17:16 +00:00
|
|
|
];
|
2022-09-27 15:26:53 +00:00
|
|
|
|
2023-03-15 12:12:37 +00:00
|
|
|
buildInputs = [
|
|
|
|
openssl
|
2023-11-15 17:45:16 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
2023-03-15 12:12:37 +00:00
|
|
|
];
|
2021-05-19 13:51:52 +00:00
|
|
|
|
2024-03-11 15:42:20 +00:00
|
|
|
propagatedBuildInputs = with python.pkgs; [
|
2023-03-15 12:12:37 +00:00
|
|
|
attrs
|
2018-11-01 16:48:40 +00:00
|
|
|
bcrypt
|
|
|
|
bleach
|
|
|
|
canonicaljson
|
2023-03-15 12:12:37 +00:00
|
|
|
cryptography
|
2021-05-25 18:08:42 +00:00
|
|
|
ijson
|
2023-04-11 15:07:31 +00:00
|
|
|
immutabledict
|
2018-11-01 16:48:40 +00:00
|
|
|
jinja2
|
|
|
|
jsonschema
|
2022-01-18 14:42:33 +00:00
|
|
|
matrix-common
|
2019-02-06 09:44:24 +00:00
|
|
|
msgpack
|
2018-11-01 16:48:40 +00:00
|
|
|
netaddr
|
2023-03-15 12:12:37 +00:00
|
|
|
packaging
|
2018-11-01 16:48:40 +00:00
|
|
|
phonenumbers
|
|
|
|
pillow
|
2021-08-26 00:08:48 +00:00
|
|
|
prometheus-client
|
2018-11-01 16:48:40 +00:00
|
|
|
pyasn1
|
2023-03-15 12:12:37 +00:00
|
|
|
pyasn1-modules
|
2022-08-31 13:59:46 +00:00
|
|
|
pydantic
|
2019-02-06 09:44:24 +00:00
|
|
|
pymacaroons
|
2018-11-01 16:48:40 +00:00
|
|
|
pyopenssl
|
|
|
|
pyyaml
|
2023-03-15 12:12:37 +00:00
|
|
|
service-identity
|
2018-11-01 16:48:40 +00:00
|
|
|
signedjson
|
|
|
|
sortedcontainers
|
|
|
|
treq
|
|
|
|
twisted
|
2019-10-29 17:23:41 +00:00
|
|
|
typing-extensions
|
2021-05-25 18:08:42 +00:00
|
|
|
unpaddedbase64
|
2023-03-15 12:12:37 +00:00
|
|
|
]
|
|
|
|
++ twisted.optional-dependencies.tls;
|
|
|
|
|
2024-03-11 15:42:20 +00:00
|
|
|
passthru.optional-dependencies = with python.pkgs; {
|
2023-03-15 12:12:37 +00:00
|
|
|
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
|
|
|
|
];
|
|
|
|
};
|
2016-01-08 14:12:00 +00:00
|
|
|
|
2023-03-15 12:12:37 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
openssl
|
2024-03-11 15:42:20 +00:00
|
|
|
] ++ (with python.pkgs; [
|
2023-03-15 12:12:37 +00:00
|
|
|
mock
|
|
|
|
parameterized
|
|
|
|
])
|
|
|
|
++ lib.flatten (lib.attrValues passthru.optional-dependencies);
|
2016-01-08 14:12:00 +00:00
|
|
|
|
2019-10-18 20:03:51 +00:00
|
|
|
doCheck = !stdenv.isDarwin;
|
|
|
|
|
matrix-synapse: limit parallelism to 4 cores to be improve stability, formatting
On high core machines those easily can fail similar to:
matrix-synapse> tests.storage.test_room_search.MessageSearchTest.test_postgres_web_search_for_phrase
matrix-synapse> ===============================================================================
matrix-synapse> [ERROR]
matrix-synapse> Traceback (most recent call last):
matrix-synapse> File "/build/source/tests/unittest.py", line 122, in new
matrix-synapse> return code(orig, *args, **kwargs)
matrix-synapse> File "/build/source/tests/unittest.py", line 216, in setUp
matrix-synapse> return orig()
matrix-synapse> File "/build/source/tests/unittest.py", line 338, in setUp
matrix-synapse> self.hs = self.make_homeserver(self.reactor, self.clock)
matrix-synapse> File "/build/source/tests/app/test_openid_listener.py", line 34, in make_homeserver
matrix-synapse> hs = self.setup_test_homeserver(
matrix-synapse> File "/build/source/tests/unittest.py", line 606, in setup_test_homeserver
matrix-synapse> hs = setup_test_homeserver(self.addCleanup, **kwargs)
matrix-synapse> File "/build/source/tests/server.py", line 921, in setup_test_homeserver
matrix-synapse> prepare_database(
matrix-synapse> File "/nix/store/2cc0p5apn2yg2fr5ii9mvb7fcwd74y26-matrix-synapse-1.86.0/lib/python3.10/site-packages/synapse/storage/prepare_database.py", line 155, in prepare_database
matrix-synapse> raise UpgradeDatabaseException(EMPTY_DATABASE_ON_WORKER_ERROR)
matrix-synapse> synapse.storage.prepare_database.UpgradeDatabaseException: Uninitialised database: run the main synapse process to prepare the database schema before starting worker processes.
matrix-synapse>
2023-07-02 22:19:30 +00:00
|
|
|
checkPhase = ''
|
2022-09-27 15:26:53 +00:00
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
# remove src module, so tests use the installed module instead
|
|
|
|
rm -rf ./synapse
|
|
|
|
|
matrix-synapse: limit parallelism to 4 cores to be improve stability, formatting
On high core machines those easily can fail similar to:
matrix-synapse> tests.storage.test_room_search.MessageSearchTest.test_postgres_web_search_for_phrase
matrix-synapse> ===============================================================================
matrix-synapse> [ERROR]
matrix-synapse> Traceback (most recent call last):
matrix-synapse> File "/build/source/tests/unittest.py", line 122, in new
matrix-synapse> return code(orig, *args, **kwargs)
matrix-synapse> File "/build/source/tests/unittest.py", line 216, in setUp
matrix-synapse> return orig()
matrix-synapse> File "/build/source/tests/unittest.py", line 338, in setUp
matrix-synapse> self.hs = self.make_homeserver(self.reactor, self.clock)
matrix-synapse> File "/build/source/tests/app/test_openid_listener.py", line 34, in make_homeserver
matrix-synapse> hs = self.setup_test_homeserver(
matrix-synapse> File "/build/source/tests/unittest.py", line 606, in setup_test_homeserver
matrix-synapse> hs = setup_test_homeserver(self.addCleanup, **kwargs)
matrix-synapse> File "/build/source/tests/server.py", line 921, in setup_test_homeserver
matrix-synapse> prepare_database(
matrix-synapse> File "/nix/store/2cc0p5apn2yg2fr5ii9mvb7fcwd74y26-matrix-synapse-1.86.0/lib/python3.10/site-packages/synapse/storage/prepare_database.py", line 155, in prepare_database
matrix-synapse> raise UpgradeDatabaseException(EMPTY_DATABASE_ON_WORKER_ERROR)
matrix-synapse> synapse.storage.prepare_database.UpgradeDatabaseException: Uninitialised database: run the main synapse process to prepare the database schema before starting worker processes.
matrix-synapse>
2023-07-02 22:19:30 +00:00
|
|
|
# high parallelisem makes test suite unstable
|
|
|
|
# upstream uses 2 cores but 4 seems to be also stable
|
2023-12-13 22:48:09 +00:00
|
|
|
# https://github.com/element-hq/synapse/blob/develop/.github/workflows/latest_deps.yml#L103
|
matrix-synapse: limit parallelism to 4 cores to be improve stability, formatting
On high core machines those easily can fail similar to:
matrix-synapse> tests.storage.test_room_search.MessageSearchTest.test_postgres_web_search_for_phrase
matrix-synapse> ===============================================================================
matrix-synapse> [ERROR]
matrix-synapse> Traceback (most recent call last):
matrix-synapse> File "/build/source/tests/unittest.py", line 122, in new
matrix-synapse> return code(orig, *args, **kwargs)
matrix-synapse> File "/build/source/tests/unittest.py", line 216, in setUp
matrix-synapse> return orig()
matrix-synapse> File "/build/source/tests/unittest.py", line 338, in setUp
matrix-synapse> self.hs = self.make_homeserver(self.reactor, self.clock)
matrix-synapse> File "/build/source/tests/app/test_openid_listener.py", line 34, in make_homeserver
matrix-synapse> hs = self.setup_test_homeserver(
matrix-synapse> File "/build/source/tests/unittest.py", line 606, in setup_test_homeserver
matrix-synapse> hs = setup_test_homeserver(self.addCleanup, **kwargs)
matrix-synapse> File "/build/source/tests/server.py", line 921, in setup_test_homeserver
matrix-synapse> prepare_database(
matrix-synapse> File "/nix/store/2cc0p5apn2yg2fr5ii9mvb7fcwd74y26-matrix-synapse-1.86.0/lib/python3.10/site-packages/synapse/storage/prepare_database.py", line 155, in prepare_database
matrix-synapse> raise UpgradeDatabaseException(EMPTY_DATABASE_ON_WORKER_ERROR)
matrix-synapse> synapse.storage.prepare_database.UpgradeDatabaseException: Uninitialised database: run the main synapse process to prepare the database schema before starting worker processes.
matrix-synapse>
2023-07-02 22:19:30 +00:00
|
|
|
if (( $NIX_BUILD_CORES > 4)); then
|
|
|
|
NIX_BUILD_CORES=4
|
|
|
|
fi
|
|
|
|
|
2024-03-11 15:42:20 +00:00
|
|
|
PYTHONPATH=".:$PYTHONPATH" ${python.interpreter} -m twisted.trial -j $NIX_BUILD_CORES tests
|
2022-09-27 15:26:53 +00:00
|
|
|
|
|
|
|
runHook postCheck
|
2019-01-11 09:33:07 +00:00
|
|
|
'';
|
2016-01-08 14:12:00 +00:00
|
|
|
|
matrix-synapse: limit parallelism to 4 cores to be improve stability, formatting
On high core machines those easily can fail similar to:
matrix-synapse> tests.storage.test_room_search.MessageSearchTest.test_postgres_web_search_for_phrase
matrix-synapse> ===============================================================================
matrix-synapse> [ERROR]
matrix-synapse> Traceback (most recent call last):
matrix-synapse> File "/build/source/tests/unittest.py", line 122, in new
matrix-synapse> return code(orig, *args, **kwargs)
matrix-synapse> File "/build/source/tests/unittest.py", line 216, in setUp
matrix-synapse> return orig()
matrix-synapse> File "/build/source/tests/unittest.py", line 338, in setUp
matrix-synapse> self.hs = self.make_homeserver(self.reactor, self.clock)
matrix-synapse> File "/build/source/tests/app/test_openid_listener.py", line 34, in make_homeserver
matrix-synapse> hs = self.setup_test_homeserver(
matrix-synapse> File "/build/source/tests/unittest.py", line 606, in setup_test_homeserver
matrix-synapse> hs = setup_test_homeserver(self.addCleanup, **kwargs)
matrix-synapse> File "/build/source/tests/server.py", line 921, in setup_test_homeserver
matrix-synapse> prepare_database(
matrix-synapse> File "/nix/store/2cc0p5apn2yg2fr5ii9mvb7fcwd74y26-matrix-synapse-1.86.0/lib/python3.10/site-packages/synapse/storage/prepare_database.py", line 155, in prepare_database
matrix-synapse> raise UpgradeDatabaseException(EMPTY_DATABASE_ON_WORKER_ERROR)
matrix-synapse> synapse.storage.prepare_database.UpgradeDatabaseException: Uninitialised database: run the main synapse process to prepare the database schema before starting worker processes.
matrix-synapse>
2023-07-02 22:19:30 +00:00
|
|
|
passthru = {
|
2023-09-11 08:12:06 +00:00
|
|
|
tests = { inherit (nixosTests) matrix-synapse matrix-synapse-workers; };
|
2024-03-11 15:42:20 +00:00
|
|
|
inherit plugins tools python;
|
matrix-synapse: limit parallelism to 4 cores to be improve stability, formatting
On high core machines those easily can fail similar to:
matrix-synapse> tests.storage.test_room_search.MessageSearchTest.test_postgres_web_search_for_phrase
matrix-synapse> ===============================================================================
matrix-synapse> [ERROR]
matrix-synapse> Traceback (most recent call last):
matrix-synapse> File "/build/source/tests/unittest.py", line 122, in new
matrix-synapse> return code(orig, *args, **kwargs)
matrix-synapse> File "/build/source/tests/unittest.py", line 216, in setUp
matrix-synapse> return orig()
matrix-synapse> File "/build/source/tests/unittest.py", line 338, in setUp
matrix-synapse> self.hs = self.make_homeserver(self.reactor, self.clock)
matrix-synapse> File "/build/source/tests/app/test_openid_listener.py", line 34, in make_homeserver
matrix-synapse> hs = self.setup_test_homeserver(
matrix-synapse> File "/build/source/tests/unittest.py", line 606, in setup_test_homeserver
matrix-synapse> hs = setup_test_homeserver(self.addCleanup, **kwargs)
matrix-synapse> File "/build/source/tests/server.py", line 921, in setup_test_homeserver
matrix-synapse> prepare_database(
matrix-synapse> File "/nix/store/2cc0p5apn2yg2fr5ii9mvb7fcwd74y26-matrix-synapse-1.86.0/lib/python3.10/site-packages/synapse/storage/prepare_database.py", line 155, in prepare_database
matrix-synapse> raise UpgradeDatabaseException(EMPTY_DATABASE_ON_WORKER_ERROR)
matrix-synapse> synapse.storage.prepare_database.UpgradeDatabaseException: Uninitialised database: run the main synapse process to prepare the database schema before starting worker processes.
matrix-synapse>
2023-07-02 22:19:30 +00:00
|
|
|
};
|
2019-10-03 13:59:06 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://matrix.org";
|
2023-12-13 22:48:09 +00:00
|
|
|
changelog = "https://github.com/element-hq/synapse/releases/tag/v${version}";
|
2016-01-08 14:12:00 +00:00
|
|
|
description = "Matrix reference homeserver";
|
2023-12-13 23:01:16 +00:00
|
|
|
license = licenses.agpl3Plus;
|
2020-06-12 01:05:26 +00:00
|
|
|
maintainers = teams.matrix.members;
|
2016-01-08 14:12:00 +00:00
|
|
|
};
|
|
|
|
}
|