add mautrix-telegram

This commit is contained in:
Charlotte 🦝 Delenk 2022-09-26 11:39:55 +01:00
parent 700e014bc6
commit b78992497c
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
8 changed files with 147 additions and 43 deletions

View file

@ -34,5 +34,7 @@
mautrix-discord = pkgs.callPackage ./matrix/mautrix-discord {}; mautrix-discord = pkgs.callPackage ./matrix/mautrix-discord {};
mautrix-whatsapp = pkgs.callPackage ./matrix/mautrix-whatsapp {}; mautrix-whatsapp = pkgs.callPackage ./matrix/mautrix-whatsapp {};
mautrix-signal = pkgs.callPackage ./matrix/mautrix-signal {}; mautrix-signal = pkgs.callPackage ./matrix/mautrix-signal {};
mautrix-telegram = pkgs.callPackage ./matrix/mautrix-telegram {};
python-mautrix = pkgs.python3Packages.callPackage ./python/mautrix.nix {}; python-mautrix = pkgs.python3Packages.callPackage ./python/mautrix.nix {};
python-tulir-telethon = pkgs.python3Packages.callPackage ./python/tulir-telethon.nix {};
} }

View file

@ -1,37 +0,0 @@
{
inputs,
pkgs,
}:
with pkgs; let
python-packages = import ../python/packages.nix {inherit inputs pkgs;};
in {
mautrix-telegram = with python3Packages;
buildPythonPackage {
pname = "mautrix-telegram";
version = inputs.mautrix-telegram.lastModifiedDate;
src = inputs.mautrix-telegram;
patches = ["${inputs.nixpkgs}/pkgs/servers/mautrix-telegram/0001-Re-add-entrypoint.patch" ./mautrix-telegram-sticker.patch];
propagatedBuildInputs = [
Mako
aiohttp
python-packages.mautrix
sqlalchemy
CommonMark
ruamel-yaml
python-magic
python-packages.tulir-telethon
telethon-session-sqlalchemy
pillow
lxml
setuptools
prometheus-client
asyncpg
python-olm
pycryptodome
unpaddedbase64
psycopg2
aiosqlite
];
doCheck = false;
};
}

View file

@ -0,0 +1,27 @@
From f4a612e1c8501d2a1683003bb121daa6d46155ca Mon Sep 17 00:00:00 2001
From: Maximilian Bosch <maximilian@mbosch.me>
Date: Sun, 29 Nov 2020 20:45:16 +0100
Subject: [PATCH 1/2] Re-add entrypoint
---
setup.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/setup.py b/setup.py
index ea001e5..e1ca536 100644
--- a/setup.py
+++ b/setup.py
@@ -54,6 +54,12 @@ setuptools.setup(
extras_require=extras_require,
python_requires="~=3.7",
+ entry_points={
+ 'console_scripts': [
+ 'mautrix-telegram=mautrix_telegram.__main__:main'
+ ]
+ },
+
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",

View file

@ -0,0 +1,62 @@
{
lib,
python3,
fetchFromGitHub,
}: let
source = builtins.fromJSON (builtins.readFile ./source.json);
python = python3;
in
python.pkgs.buildPythonPackage rec {
pname = "mautrix-telegram";
version = source.date;
disabled = python.pythonOlder "3.8";
src = fetchFromGitHub {
owner = "mautrix";
repo = "telegram";
inherit (source) rev sha256;
};
patches = [./0001-Re-add-entrypoint.patch ./mautrix-telegram-sticker.patch];
propagatedBuildInputs = with python.pkgs; [
ruamel-yaml
python-magic
CommonMark
aiohttp
yarl
mautrix
(python.pkgs.callPackage ../../python/tulir-telethon.nix {})
asyncpg
Mako
# optional
cryptg
cchardet
aiodns
brotli
pillow
qrcode
phonenumbers
prometheus-client
aiosqlite
moviepy
python-olm
pycryptodome
unpaddedbase64
];
# has no tests
doCheck = false;
meta = with lib; {
homepage = "https://github.com/mautrix/telegram";
description = "A Matrix-Telegram hybrid puppeting/relaybot bridge";
license = licenses.agpl3Plus;
platforms = platforms.linux;
};
passthru.updateScript = [
../../scripts/update-git.sh
"https://github.com/mautrix/telegram"
"matrix/mautrix-telegram/source.json"
];
}

View file

@ -0,0 +1,11 @@
{
"url": "https://github.com/mautrix/telegram",
"rev": "5a767a2d927a8082a0fbf79091039b9209becf5c",
"date": "2022-09-25T17:06:17+03:00",
"path": "/nix/store/dx6gsx5453wjanslj8s6mjy7zip2xjir-telegram",
"sha256": "0n0fbcq83klzlshpi7i6hlrzsynj0srp4q1p8alhjh89yp8rk760",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
}

39
python/tulir-telethon.nix Normal file
View file

@ -0,0 +1,39 @@
{
lib,
buildPythonPackage,
fetchPypi,
openssl,
rsa,
pyaes,
pythonOlder,
}:
buildPythonPackage rec {
pname = "tulir-telethon";
version = "1.26.0a5";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-s6pj9kHqcl6XU1KQ/aOw1XWQ3CyDotaDl0m7aj9SbW4=";
};
patchPhase = ''
substituteInPlace telethon/crypto/libssl.py --replace \
"ctypes.util.find_library('ssl')" "'${lib.getLib openssl}/lib/libssl.so'"
'';
propagatedBuildInputs = [
rsa
pyaes
];
# No tests available
doCheck = false;
disabled = pythonOlder "3.5";
meta = with lib; {
homepage = "https://github.com/LonamiWebs/Telethon";
description = "Full-featured Telegram client library for Python 3";
license = licenses.mit;
};
}

View file

@ -46,15 +46,18 @@ class Version(_Version, collections.abc.Sequence):
# We cannot use `str(Version(0.04.21))` because that becomes `0.4.21` # We cannot use `str(Version(0.04.21))` because that becomes `0.4.21`
# https://github.com/avian2/unidecode/issues/13#issuecomment-354538882 # https://github.com/avian2/unidecode/issues/13#issuecomment-354538882
self.raw_version = version self.raw_version = version
self.full_version = list(self._version.release)
if self._version.dev is not None:
self.full_version += list(self._version.dev)
def __getitem__(self, i): def __getitem__(self, i):
return self._version.release[i] return self.full_version[i]
def __len__(self): def __len__(self):
return len(self._version.release) return len(self.full_version)
def __iter__(self): def __iter__(self):
yield from self._version.release yield from self.full_version
def _get_values(attribute, text): def _get_values(attribute, text):
@ -154,9 +157,6 @@ def _determine_latest_version(current_version, target, versions):
ceiling[-1]+=1 ceiling[-1]+=1
ceiling = Version(".".join(map(str, ceiling))) ceiling = Version(".".join(map(str, ceiling)))
# We do not want prereleases
versions = SpecifierSet(prereleases=PRERELEASES).filter(versions)
if ceiling is not None: if ceiling is not None:
versions = SpecifierSet(f"<{ceiling}").filter(versions) versions = SpecifierSet(f"<{ceiling}").filter(versions)