diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2023-08-14 18:43:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-14 18:43:05 +0200 |
commit | a471325eaf79bc615bf55155b7f708e903e643bd (patch) | |
tree | 6dc21a22326ba4177fb83805d6572a4e93705c69 /pkgs/servers/matrix-synapse | |
parent | 14ae6da134efb5e08ac584665c6bebb377da65ca (diff) | |
parent | d2facca5c0c776bef2e142e129df90355ec80a27 (diff) |
Merge pull request #221318 from mweinelt/synapse-extras
nixos/matrix-synapse: Allow passing extras, discover extras from config
Diffstat (limited to 'pkgs/servers/matrix-synapse')
-rw-r--r-- | pkgs/servers/matrix-synapse/default.nix | 90 | ||||
-rw-r--r-- | pkgs/servers/matrix-synapse/plugins/ldap3.nix | 4 | ||||
-rw-r--r-- | pkgs/servers/matrix-synapse/plugins/mjolnir-antispam.nix | 4 | ||||
-rw-r--r-- | pkgs/servers/matrix-synapse/plugins/shared-secret-auth.nix | 4 | ||||
-rw-r--r-- | pkgs/servers/matrix-synapse/wrapper.nix | 44 |
5 files changed, 119 insertions, 27 deletions
diff --git a/pkgs/servers/matrix-synapse/default.nix b/pkgs/servers/matrix-synapse/default.nix index 56650531a65d8..2d4455d322a74 100644 --- a/pkgs/servers/matrix-synapse/default.nix +++ b/pkgs/servers/matrix-synapse/default.nix @@ -1,7 +1,12 @@ -{ lib, stdenv, fetchFromGitHub, python3, openssl, cargo, rustPlatform, rustc -, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform python3.pkgs.systemd +{ lib +, stdenv +, fetchFromGitHub +, python3 +, openssl +, cargo +, rustPlatform +, rustc , nixosTests -, enableRedis ? true , callPackage }: @@ -9,8 +14,7 @@ let plugins = python3.pkgs.callPackage ./plugins { }; tools = callPackage ./tools { }; in -with python3.pkgs; -buildPythonApplication rec { +python3.pkgs.buildPythonApplication rec { pname = "matrix-synapse"; version = "1.89.0"; format = "pyproject"; @@ -34,7 +38,7 @@ buildPythonApplication rec { sed -i '/^setuptools_rust =/d' pyproject.toml ''; - nativeBuildInputs = [ + nativeBuildInputs = with python3.pkgs; [ poetry-core rustPlatform.cargoSetupHook setuptools-rust @@ -42,47 +46,90 @@ buildPythonApplication rec { rustc ]; - buildInputs = [ openssl ]; + buildInputs = [ + openssl + ]; - propagatedBuildInputs = [ - authlib + propagatedBuildInputs = with python3.pkgs; [ + attrs bcrypt bleach canonicaljson - daemonize + cryptography ijson immutabledict jinja2 jsonschema - lxml matrix-common msgpack netaddr + packaging phonenumbers pillow prometheus-client - psutil - psycopg2 pyasn1 + pyasn1-modules pydantic - pyicu pymacaroons - pynacl pyopenssl - pysaml2 pyyaml - requests - setuptools + service-identity signedjson sortedcontainers treq twisted typing-extensions unpaddedbase64 - ] ++ lib.optional enableSystemd systemd - ++ lib.optionals enableRedis [ hiredis txredisapi ]; + ] + ++ 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 + ]; + opentracing = [ + jaeger-client + opentracing + ]; + jwt = [ + authlib + ]; + redis = [ + hiredis + txredisapi + ]; + cache-memory = [ + pympler + ]; + user-search = [ + pyicu + ]; + }; - nativeCheckInputs = [ mock parameterized openssl ]; + nativeCheckInputs = [ + openssl + ] ++ (with python3.pkgs; [ + mock + parameterized + ]) + ++ lib.flatten (lib.attrValues passthru.optional-dependencies); doCheck = !stdenv.isDarwin; @@ -112,6 +159,7 @@ buildPythonApplication rec { meta = with lib; { homepage = "https://matrix.org"; + changelog = "https://github.com/matrix-org/synapse/releases/tag/v${version}"; description = "Matrix reference homeserver"; license = licenses.asl20; maintainers = teams.matrix.members; diff --git a/pkgs/servers/matrix-synapse/plugins/ldap3.nix b/pkgs/servers/matrix-synapse/plugins/ldap3.nix index b29dc21422e90..feac6f0847263 100644 --- a/pkgs/servers/matrix-synapse/plugins/ldap3.nix +++ b/pkgs/servers/matrix-synapse/plugins/ldap3.nix @@ -4,7 +4,7 @@ , fetchPypi , ldap3 , ldaptor -, matrix-synapse +, matrix-synapse-unwrapped , pytestCheckHook , service-identity , setuptools @@ -33,7 +33,7 @@ buildPythonPackage rec { propagatedBuildInputs = [ service-identity ldap3 twisted ]; - nativeCheckInputs = [ ldaptor matrix-synapse pytestCheckHook ]; + nativeCheckInputs = [ ldaptor matrix-synapse-unwrapped pytestCheckHook ]; pythonImportsCheck = [ "ldap_auth_provider" ]; diff --git a/pkgs/servers/matrix-synapse/plugins/mjolnir-antispam.nix b/pkgs/servers/matrix-synapse/plugins/mjolnir-antispam.nix index 2d0fa4115cc5d..e1a9f72859207 100644 --- a/pkgs/servers/matrix-synapse/plugins/mjolnir-antispam.nix +++ b/pkgs/servers/matrix-synapse/plugins/mjolnir-antispam.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, buildPythonPackage, fetchFromGitHub, matrix-synapse }: +{ lib, stdenv, buildPythonPackage, fetchFromGitHub, matrix-synapse-unwrapped }: buildPythonPackage rec { pname = "matrix-synapse-mjolnir-antispam"; @@ -13,7 +13,7 @@ buildPythonPackage rec { sourceRoot = "./${src.name}/synapse_antispam"; - buildInputs = [ matrix-synapse ]; + buildInputs = [ matrix-synapse-unwrapped ]; doCheck = false; # no tests pythonImportsCheck = [ "mjolnir" ]; diff --git a/pkgs/servers/matrix-synapse/plugins/shared-secret-auth.nix b/pkgs/servers/matrix-synapse/plugins/shared-secret-auth.nix index a6e22db34fe5c..b5be02a4b21af 100644 --- a/pkgs/servers/matrix-synapse/plugins/shared-secret-auth.nix +++ b/pkgs/servers/matrix-synapse/plugins/shared-secret-auth.nix @@ -1,4 +1,4 @@ -{ lib, buildPythonPackage, fetchFromGitHub, matrix-synapse, twisted }: +{ lib, buildPythonPackage, fetchFromGitHub, matrix-synapse-unwrapped, twisted }: buildPythonPackage rec { pname = "matrix-synapse-shared-secret-auth"; @@ -14,7 +14,7 @@ buildPythonPackage rec { doCheck = false; pythonImportsCheck = [ "shared_secret_authenticator" ]; - buildInputs = [ matrix-synapse ]; + buildInputs = [ matrix-synapse-unwrapped ]; propagatedBuildInputs = [ twisted ]; meta = with lib; { diff --git a/pkgs/servers/matrix-synapse/wrapper.nix b/pkgs/servers/matrix-synapse/wrapper.nix new file mode 100644 index 0000000000000..930142c5f55e2 --- /dev/null +++ b/pkgs/servers/matrix-synapse/wrapper.nix @@ -0,0 +1,44 @@ +{ lib +, stdenv +, makeWrapper +, matrix-synapse-unwrapped +, extras ? [ + "postgres" + "url-preview" + "user-search" + ] ++ lib.optional (lib.meta.availableOn stdenv.hostPlatform matrix-synapse-unwrapped.python.pkgs.systemd) "systemd" +, plugins ? [ ] +, ... +}: + +let + extraPackages = lib.concatMap (extra: matrix-synapse-unwrapped.optional-dependencies.${extra}) (lib.unique extras); + + pluginsEnv = matrix-synapse-unwrapped.python.buildEnv.override { + extraLibs = plugins; + }; + + searchPath = lib.makeSearchPathOutput "lib" matrix-synapse-unwrapped.python.sitePackages (extraPackages ++ [ pluginsEnv ]); +in +stdenv.mkDerivation { + name = (lib.appendToName "wrapped" matrix-synapse-unwrapped).name; + + nativeBuildInputs = [ + makeWrapper + ]; + + buildCommand = '' + for bin in ${matrix-synapse-unwrapped}/bin/*; do + echo $bin + makeWrapper "$bin" "$out/bin/$(basename $bin)" \ + --set PYTHONPATH ${searchPath} + done; + ''; + + passthru = { + unwrapped = matrix-synapse-unwrapped; + + # for backward compatibility + inherit (matrix-synapse-unwrapped) plugins tools; + }; +} |