diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/networking/instant-messengers/telegram')
6 files changed, 461 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix new file mode 100644 index 000000000000..d9f9cd91a52d --- /dev/null +++ b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix @@ -0,0 +1,74 @@ +{ mkDerivation, lib, fetchFromGitHub, callPackage +, pkg-config, cmake, ninja, python3, wrapGAppsHook, wrapQtAppsHook +, qtbase, qtimageformats, gtk3, libsForQt5, lz4, xxHash +, ffmpeg, openalSoft, minizip, libopus, alsa-lib, libpulseaudio, range-v3 +, tl-expected, hunspell, glibmm, webkitgtk +# Transitive dependencies: +, pcre, xorg, util-linux, libselinux, libsepol, epoxy +, at-spi2-core, libXtst, libthai, libdatrie +}: + +with lib; + +let + tg_owt = callPackage ./tg_owt.nix {}; +in mkDerivation rec { + pname = "kotatogram-desktop"; + version = "1.4.1"; + + src = fetchFromGitHub { + owner = "kotatogram"; + repo = "kotatogram-desktop"; + rev = "k${version}"; + sha256 = "07z56gz3sk45n5j0gw9p9mxrbwixxsmp7lvqc6lqnxmglz6knc1d"; + fetchSubmodules = true; + }; + + postPatch = '' + substituteInPlace Telegram/CMakeLists.txt \ + --replace '"''${TDESKTOP_LAUNCHER_BASENAME}.appdata.xml"' '"''${TDESKTOP_LAUNCHER_BASENAME}.metainfo.xml"' + ''; + + # We want to run wrapProgram manually (with additional parameters) + dontWrapGApps = true; + dontWrapQtApps = true; + + nativeBuildInputs = [ pkg-config cmake ninja python3 wrapGAppsHook wrapQtAppsHook ]; + + buildInputs = [ + qtbase qtimageformats gtk3 libsForQt5.kwayland libsForQt5.libdbusmenu lz4 xxHash + ffmpeg openalSoft minizip libopus alsa-lib libpulseaudio range-v3 + tl-expected hunspell glibmm webkitgtk + tg_owt + # Transitive dependencies: + pcre xorg.libXdmcp util-linux libselinux libsepol epoxy + at-spi2-core libXtst libthai libdatrie + ]; + + cmakeFlags = [ "-DTDESKTOP_API_TEST=ON" ]; + + postFixup = '' + # We also use gappsWrapperArgs from wrapGAppsHook. + wrapProgram $out/bin/kotatogram-desktop \ + "''${gappsWrapperArgs[@]}" \ + "''${qtWrapperArgs[@]}" + ''; + + passthru = { + inherit tg_owt; + }; + + meta = { + description = "Kotatogram – experimental Telegram Desktop fork"; + longDescription = '' + Unofficial desktop client for the Telegram messenger, based on Telegram Desktop. + + It contains some useful (or purely cosmetic) features, but they could be unstable. A detailed list is available here: https://kotatogram.github.io/changes + ''; + license = licenses.gpl3; + platforms = platforms.linux; + homepage = "https://kotatogram.github.io"; + changelog = "https://github.com/kotatogram/kotatogram-desktop/releases/tag/k{ver}"; + maintainers = with maintainers; [ ilya-fedin ]; + }; +} diff --git a/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/tg_owt.nix b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/tg_owt.nix new file mode 100644 index 000000000000..614183b72d08 --- /dev/null +++ b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/tg_owt.nix @@ -0,0 +1,36 @@ +{ lib, stdenv, fetchFromGitHub, pkg-config, cmake, ninja, yasm +, libjpeg, openssl, libopus, ffmpeg, alsa-lib, libpulseaudio, protobuf +, xorg, libXtst +}: + +let + rev = "2d804d2c9c5d05324c8ab22f2e6ff8306521b3c3"; + sha256 = "0kz0i381iwsgcc3yzsq7njx3gkqja4bb9fsgc24vhg0md540qhyn"; + +in stdenv.mkDerivation { + pname = "tg_owt"; + version = "git-${rev}"; + + src = fetchFromGitHub { + owner = "desktop-app"; + repo = "tg_owt"; + inherit rev sha256; + fetchSubmodules = true; + }; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ pkg-config cmake ninja yasm ]; + + buildInputs = [ + libjpeg openssl libopus ffmpeg alsa-lib libpulseaudio protobuf + xorg.libX11 libXtst + ]; + + cmakeFlags = [ + # Building as a shared library isn't officially supported and currently broken: + "-DBUILD_SHARED_LIBS=OFF" + ]; + + meta.license = lib.licenses.bsd3; +} diff --git a/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix new file mode 100644 index 000000000000..d39ac978d8d3 --- /dev/null +++ b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix @@ -0,0 +1,183 @@ +{ mkDerivation +, lib +, fetchFromGitHub +, callPackage +, pkg-config +, cmake +, ninja +, python3 +, wrapGAppsHook +, wrapQtAppsHook +, extra-cmake-modules +, qtbase +, qtimageformats +, gtk3 +, kwayland +, libdbusmenu +, lz4 +, xxHash +, ffmpeg +, openalSoft +, minizip +, libopus +, alsa-lib +, libpulseaudio +, range-v3 +, tl-expected +, hunspell +, glibmm +, webkitgtk +, jemalloc +, rnnoise + # Transitive dependencies: +, util-linuxMinimal +, pcre +, libpthreadstubs +, libXdmcp +, libselinux +, libsepol +, epoxy +, at-spi2-core +, libXtst +, libthai +, libdatrie +, xdg-utils +, libsysprof-capture +, libpsl +, brotli +, microsoft_gsl +, rlottie +}: + +# Main reference: +# - This package was originally based on the Arch package but all patches are now upstreamed: +# https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/telegram-desktop +# Other references that could be useful: +# - https://git.alpinelinux.org/aports/tree/testing/telegram-desktop/APKBUILD +# - https://github.com/void-linux/void-packages/blob/master/srcpkgs/telegram-desktop/template + +let + tg_owt = callPackage ./tg_owt.nix { }; +in +mkDerivation rec { + pname = "telegram-desktop"; + version = "3.1.9"; + # Note: Update via pkgs/applications/networking/instant-messengers/telegram/tdesktop/update.py + + # Telegram-Desktop with submodules + src = fetchFromGitHub { + owner = "telegramdesktop"; + repo = "tdesktop"; + rev = "v${version}"; + fetchSubmodules = true; + sha256 = "1nmakl9jxmw3k8gka56cyywbjwv06a5983dy6h9jhkkq950fn33s"; + }; + + postPatch = '' + substituteInPlace Telegram/CMakeLists.txt \ + --replace '"''${TDESKTOP_LAUNCHER_BASENAME}.appdata.xml"' '"''${TDESKTOP_LAUNCHER_BASENAME}.metainfo.xml"' + + substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp \ + --replace '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"' + substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp \ + --replace '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"' + substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioPulse.cpp \ + --replace '"libpulse.so.0"' '"${libpulseaudio}/lib/libpulse.so.0"' + substituteInPlace Telegram/lib_webview/webview/platform/linux/webview_linux_webkit_gtk.cpp \ + --replace '"libwebkit2gtk-4.0.so.37"' '"${webkitgtk}/lib/libwebkit2gtk-4.0.so.37"' + ''; + + # We want to run wrapProgram manually (with additional parameters) + dontWrapGApps = true; + dontWrapQtApps = true; + + nativeBuildInputs = [ + pkg-config + cmake + ninja + python3 + wrapGAppsHook + wrapQtAppsHook + extra-cmake-modules + ]; + + buildInputs = [ + qtbase + qtimageformats + gtk3 + kwayland + libdbusmenu + lz4 + xxHash + ffmpeg + openalSoft + minizip + libopus + alsa-lib + libpulseaudio + range-v3 + tl-expected + hunspell + glibmm + webkitgtk + jemalloc + rnnoise + tg_owt + # Transitive dependencies: + util-linuxMinimal # Required for libmount thus not nativeBuildInputs. + pcre + libpthreadstubs + libXdmcp + libselinux + libsepol + epoxy + at-spi2-core + libXtst + libthai + libdatrie + libsysprof-capture + libpsl + brotli + microsoft_gsl + rlottie + ]; + + cmakeFlags = [ + "-Ddisable_autoupdate=ON" + # We're allowed to used the API ID of the Snap package: + "-DTDESKTOP_API_ID=611335" + "-DTDESKTOP_API_HASH=d524b414d21f4d37f08684c1df41ac9c" + # See: https://github.com/NixOS/nixpkgs/pull/130827#issuecomment-885212649 + "-DDESKTOP_APP_USE_PACKAGED_FONTS=OFF" + ]; + + postFixup = '' + # This is necessary to run Telegram in a pure environment. + # We also use gappsWrapperArgs from wrapGAppsHook. + wrapProgram $out/bin/telegram-desktop \ + "''${gappsWrapperArgs[@]}" \ + "''${qtWrapperArgs[@]}" \ + --prefix PATH : ${lib.makeBinPath [ xdg-utils]} \ + --set XDG_RUNTIME_DIR "XDG-RUNTIME-DIR" + sed -i $out/bin/telegram-desktop \ + -e "s,'XDG-RUNTIME-DIR',\"\''${XDG_RUNTIME_DIR:-/run/user/\$(id --user)}\"," + ''; + + passthru = { + inherit tg_owt; + updateScript = ./update.py; + }; + + meta = with lib; { + description = "Telegram Desktop messaging app"; + longDescription = '' + Desktop client for the Telegram messenger, based on the Telegram API and + the MTProto secure protocol. + ''; + license = licenses.gpl3Only; + platforms = platforms.linux; + homepage = "https://desktop.telegram.org/"; + changelog = "https://github.com/telegramdesktop/tdesktop/releases/tag/v${version}"; + maintainers = with maintainers; [ oxalica primeos vanilla ]; + }; +} diff --git a/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/tg_owt.nix b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/tg_owt.nix new file mode 100644 index 000000000000..60baf734aa1a --- /dev/null +++ b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/tg_owt.nix @@ -0,0 +1,46 @@ +{ lib, stdenv, fetchFromGitHub +, pkg-config, cmake, ninja, yasm +, libjpeg, openssl, libopus, ffmpeg, alsa-lib, libpulseaudio, protobuf +, openh264, usrsctp, libevent, libvpx +, libX11, libXtst, libXcomposite, libXdamage, libXext, libXrender, libXrandr, libXi +, glib, abseil-cpp, pcre, util-linuxMinimal, libselinux, libsepol, pipewire +}: + +stdenv.mkDerivation { + pname = "tg_owt"; + version = "unstable-2021-09-15"; + + src = fetchFromGitHub { + owner = "desktop-app"; + repo = "tg_owt"; + rev = "575fb17d2853c43329e45f6693370f5e41668055"; + sha256 = "17lhy5g4apdakspv75zm070k7003crf1i80m8wy8f631s86v30md"; + fetchSubmodules = true; + }; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ pkg-config cmake ninja yasm ]; + + buildInputs = [ + libjpeg openssl libopus ffmpeg alsa-lib libpulseaudio protobuf + openh264 usrsctp libevent libvpx + libX11 libXtst libXcomposite libXdamage libXext libXrender libXrandr libXi + glib abseil-cpp pcre util-linuxMinimal libselinux libsepol pipewire + ]; + + cmakeFlags = [ + # Building as a shared library isn't officially supported and may break at any time. + "-DBUILD_SHARED_LIBS=OFF" + ]; + + propagatedBuildInputs = [ + # Required for linking downstream binaries. + abseil-cpp openh264 usrsctp libevent libvpx + ]; + + meta = with lib; { + license = licenses.bsd3; + maintainers = with maintainers; [ oxalica ]; + }; +} diff --git a/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/update.py b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/update.py new file mode 100755 index 000000000000..89e40218623b --- /dev/null +++ b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/update.py @@ -0,0 +1,73 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i python3 -p python3 nix nix-prefetch-git + +import fileinput +import json +import os +import re +import subprocess + +from datetime import datetime +from urllib.request import urlopen, Request + + +DIR = os.path.dirname(os.path.abspath(__file__)) +HEADERS = {'Accept': 'application/vnd.github.v3+json'} + + +def github_api_request(endpoint): + base_url = 'https://api.github.com/' + request = Request(base_url + endpoint, headers=HEADERS) + with urlopen(request) as http_response: + return json.loads(http_response.read().decode('utf-8')) + + +def get_commit_date(repo, sha): + url = f'https://api.github.com/repos/{repo}/commits/{sha}' + request = Request(url, headers=HEADERS) + with urlopen(request) as http_response: + commit = json.loads(http_response.read().decode()) + date = commit['commit']['committer']['date'].rstrip('Z') + date = datetime.fromisoformat(date).date().isoformat() + return 'unstable-' + date + + +def nix_prefetch_git(url, rev): + """Prefetches the requested Git revision (incl. submodules) of the given repository URL.""" + print(f'nix-prefetch-git {url} {rev}') + out = subprocess.check_output(['nix-prefetch-git', '--quiet', '--url', url, '--rev', rev, '--fetch-submodules']) + return json.loads(out)['sha256'] + + +def nix_prefetch_url(url, unpack=False): + """Prefetches the content of the given URL.""" + print(f'nix-prefetch-url {url}') + options = ['--type', 'sha256'] + if unpack: + options += ['--unpack'] + out = subprocess.check_output(['nix-prefetch-url'] + options + [url]) + return out.decode('utf-8').rstrip() + + +def update_file(relpath, version, sha256, rev=None): + file_path = os.path.join(DIR, relpath) + with fileinput.FileInput(file_path, inplace=True) as f: + for line in f: + result = line + result = re.sub(r'^ version = ".+";', f' version = "{version}";', result) + result = re.sub(r'^ sha256 = ".+";', f' sha256 = "{sha256}";', result) + if rev: + result = re.sub(r'^ rev = ".*";', f' rev = "{rev}";', result) + print(result, end='') + + +if __name__ == "__main__": + tdesktop_tag = github_api_request('repos/telegramdesktop/tdesktop/releases/latest')['tag_name'] + tdesktop_version = tdesktop_tag.lstrip('v') + tdesktop_hash = nix_prefetch_git('https://github.com/telegramdesktop/tdesktop.git', tdesktop_tag) + update_file('default.nix', tdesktop_version, tdesktop_hash) + tg_owt_ref = github_api_request('repos/desktop-app/tg_owt/commits/master')['sha'] + tg_owt_version = get_commit_date('desktop-app/tg_owt', tg_owt_ref) + tg_owt_hash = nix_prefetch_git('https://github.com/desktop-app/tg_owt.git', tg_owt_ref) + update_file('tg_owt.nix', tg_owt_version, tg_owt_hash, tg_owt_ref) + tg_owt_ref = github_api_request('repos/desktop-app/tg_owt/commits/master')['sha'] diff --git a/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/telegram-cli/default.nix b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/telegram-cli/default.nix new file mode 100644 index 000000000000..bff3d3769a7a --- /dev/null +++ b/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/telegram-cli/default.nix @@ -0,0 +1,49 @@ +{ stdenv, fetchFromGitHub, jansson, lib, libconfig, libevent, libgcrypt, lua, lua53Packages +, makeWrapper, openssl, pkg-config, python3, readline, zlib +}: + +stdenv.mkDerivation rec { + pname = "telegram-cli"; + version = "20200106"; + + src = fetchFromGitHub { + owner = "kenorb-contrib"; + repo = "tg"; + rev = "refs/tags/${version}"; + sha256 = "sha256-wYBPr2b8IOycO9y/CNyGjnRsyGyYl3oiXYtTzwTurVA="; + fetchSubmodules = true; + }; + + buildInputs = [ + jansson + libconfig + libevent + libgcrypt + lua + lua53Packages.lgi + openssl + python3 + readline + zlib + ]; + nativeBuildInputs = [ + pkg-config + makeWrapper + ]; + + installPhase = '' + runHook preInstall + install -Dm755 ./bin/telegram-cli $out/bin/telegram-cli-keyless + install -Dm644 ./tg-server.pub -t $out/share/telegram-cli + makeWrapper $out/bin/telegram-cli-keyless $out/bin/telegram-cli \ + --add-flags "-k $out/share/telegram-cli/tg-server.pub" + runHook postInstall + ''; + + meta = with lib; { + description = "Command-line interface for Telegram, that uses readline interface, it's a client implementation of TGL library"; + downloadPage = "https://github.com/kenorb-contrib/tg"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ superherointj ]; + }; +} |