git.iko.soy/typeable/nixpkgs
on master help sign in
mautrix-telegram: patch away alembic dependency

`alembic`[1] is a database migration tool which is invoked from the CLI when installing the telegram bridge, but never needed during the runtime. The reason why `alembic` is required here is to ensure that it exists in the Python environment when deploying the bridge. However `alembic` requires `mautrix-telegram` in its environment to create a database schema from the Python models. Such a dependency relation may be possible with tools like virtualenv, however it'll result in an infinite recursion at evaluation time in Nix. With this patch, `mautrix-telegram` doesn't depend on `alembic` anymore and provides a patched alembic (`pkgs.mautrix-telegram.alembic`) which has `mautrix-telegram` in its path. [1] https://alembic.sqlalchemy.org/en/latest/

commit0a94f89fca3182cde82c91400db35e542215af97 authorMaximilian Bosch <maximilian@mbosch.me> dateSun 14 Apr 2019, 12:02 (8 years ago) parentf839011
2 files changed+20−4
pkgs/servers/mautrix-telegram/default.nix+19−3 pkgs/top-level/all-packages.nix+1−1
pkgs/servers/mautrix-telegram/default.nix+19−3
@@ -1,4 +1,4 @@
1−{ lib, python3 }:
1+{ lib, python3, mautrix-telegram }:
22
33with python3.pkgs;
44
@@ -11,11 +11,15 @@ buildPythonPackage rec {
1111 sha256 = "51951845e52c4ca5410e0f4a51d99014dd6df2fcedfca8b7241e045359cbf112";
1212 };
1313
14+ postPatch = ''
15+ sed -i -e '/alembic>/d' setup.py
16+ '';
17+
1418 propagatedBuildInputs = [
19+ Mako
1520 aiohttp
1621 mautrix-appservice
1722 sqlalchemy
18− alembic
1923 CommonMark
2024 ruamel_yaml
2125 future-fstrings
@@ -26,6 +30,18 @@ buildPythonPackage rec {
2630 lxml
2731 ];
2832
33+ # `alembic` (a database migration tool) is only needed for the initial setup,
34+ # and not needed during the actual runtime. However `alembic` requires `mautrix-telegram`
35+ # in its environment to create a database schema from all models.
36+ #
37+ # Hence we need to patch away `alembic` from `mautrix-telegram` and create an `alembic`
38+ # which has `mautrix-telegram` in its environment.
39+ passthru.alembic = alembic.overrideAttrs (old: {
40+ propagatedBuildInputs = old.propagatedBuildInputs ++ [
41+ mautrix-telegram
42+ ];
43+ });
44+
2945 checkInputs = [
3046 pytest
3147 pytestrunner
@@ -37,6 +53,6 @@ buildPythonPackage rec {
3753 homepage = https://github.com/tulir/mautrix-telegram;
3854 description = "A Matrix-Telegram hybrid puppeting/relaybot bridge";
3955 license = licenses.agpl3Plus;
40− maintainers = with maintainers; [ nyanloutre ];
56+ maintainers = with maintainers; [ nyanloutre ma27 ];
4157 };
4258}
pkgs/top-level/all-packages.nix+1−1
@@ -3908,7 +3908,7 @@ in
39083908
39093909 matrix-synapse = callPackage ../servers/matrix-synapse { };
39103910
3911− mautrix-telegram = callPackage ../servers/mautrix-telegram { };
3911+ mautrix-telegram = recurseIntoAttrs (callPackage ../servers/mautrix-telegram { });
39123912
39133913 mautrix-whatsapp = callPackage ../servers/mautrix-whatsapp { };
39143914