diff --git a/pkgs/servers/mautrix-telegram/default.nix b/pkgs/servers/mautrix-telegram/default.nix new file mode 100644 index 000000000000..9aa4fc24e4bf --- /dev/null +++ b/pkgs/servers/mautrix-telegram/default.nix @@ -0,0 +1,50 @@ +{ lib, fetchpatch, python3 }: + +with python3.pkgs; + +buildPythonPackage rec { + pname = "mautrix-telegram"; + version = "0.4.0.post1"; + + src = fetchPypi { + inherit pname version; + sha256 = "7a51e55a7f362013ce1cce7d850c65dc8d4651dd05c63004429bc521b461d029"; + }; + + patches = [ + (fetchpatch { + url = "https://github.com/tulir/mautrix-telegram/commit/a258c59ca3558ad91b1fee190c624763ca835d2f.patch"; + sha256 = "04z4plsmqmg38rsw9irp5xc9wdgjvg6xba69mixi5v82h9lg3zzp"; + }) + + ./fix_patch_conflicts.patch + + (fetchpatch { + url = "https://github.com/tulir/mautrix-telegram/commit/8021fcc24cbf8c88d9bcb2601333863c9615bd4f.patch"; + sha256 = "0cdfv8ggnjdwdhls1lk6498b233lvnb6175xbxr206km5mxyvqyk"; + }) + ]; + + propagatedBuildInputs = [ + aiohttp + mautrix-appservice + sqlalchemy + alembic + CommonMark + ruamel_yaml + future-fstrings + python_magic + telethon + telethon-session-sqlalchemy + ]; + + # No tests available + doCheck = false; + + meta = with lib; { + homepage = https://github.com/tulir/mautrix-telegram; + description = "A Matrix-Telegram hybrid puppeting/relaybot bridge"; + license = licenses.agpl3Plus; + maintainers = with maintainers; [ nyanloutre ]; + }; +} diff --git a/pkgs/servers/mautrix-telegram/fix_patch_conflicts.patch b/pkgs/servers/mautrix-telegram/fix_patch_conflicts.patch new file mode 100644 index 000000000000..99c902ce03b7 --- /dev/null +++ b/pkgs/servers/mautrix-telegram/fix_patch_conflicts.patch @@ -0,0 +1,27 @@ +diff --git a/mautrix_telegram/abstract_user.py b/mautrix_telegram/abstract_user.py +index 11273f8..aadaf5d 100644 +--- a/mautrix_telegram/abstract_user.py ++++ b/mautrix_telegram/abstract_user.py +@@ -21,14 +21,14 @@ import logging + import platform + + from sqlalchemy import orm +-from telethon.tl.types import Channel, ChannelForbidden, Chat, ChatForbidden, Message, \ +- MessageActionChannelMigrateFrom, MessageService, PeerUser, TypeUpdate, \ +- UpdateChannelPinnedMessage, UpdateChatAdmins, UpdateChatParticipantAdmin, \ +- UpdateChatParticipants, UpdateChatUserTyping, UpdateDeleteChannelMessages, \ +- UpdateDeleteMessages, UpdateEditChannelMessage, UpdateEditMessage, UpdateNewChannelMessage, \ +- UpdateNewMessage, UpdateReadHistoryOutbox, UpdateShortChatMessage, UpdateShortMessage, \ +- UpdateUserName, UpdateUserPhoto, UpdateUserStatus, UpdateUserTyping, User, UserStatusOffline, \ +- UserStatusOnline ++from telethon.tl.patched import MessageService, Message ++from telethon.tl.types import ( ++ Channel, ChannelForbidden, Chat, ChatForbidden, MessageActionChannelMigrateFrom, PeerUser, ++ TypeUpdate, UpdateChannelPinnedMessage, UpdateChatAdmins, UpdateChatParticipantAdmin, ++ UpdateChatParticipants, UpdateChatUserTyping, UpdateDeleteChannelMessages, UpdateDeleteMessages, ++ UpdateEditChannelMessage, UpdateEditMessage, UpdateNewChannelMessage, UpdateNewMessage, ++ UpdateReadHistoryOutbox, UpdateShortChatMessage, UpdateShortMessage, UpdateUserName, ++ UpdateUserPhoto, UpdateUserStatus, UpdateUserTyping, User, UserStatusOffline, UserStatusOnline) + + from mautrix_appservice import MatrixRequestError, AppService + from alchemysession import AlchemySessionContainer diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 465f86e1b76f..998258f4ef0f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3803,6 +3803,8 @@ in matrix-synapse = callPackage ../servers/matrix-synapse { }; + mautrix-telegram = callPackage ../servers/mautrix-telegram { }; + mdbook = callPackage ../tools/text/mdbook { inherit (darwin.apple_sdk.frameworks) CoreServices; };