From 3c3324e3feb3d1e980d4ebf49efa2dccbc7d9f24 Mon Sep 17 00:00:00 2001 From: Raghav Gururajan Date: Thu, 7 Jan 2021 19:41:42 -0500 Subject: [PATCH 13/15] gnu: Add telegram-desktop. * gnu/packages/telegram.scm: New module. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * gnu/packages/telegram.scm (telegram-desktop): New variable. --- gnu/local.mk | 1 + gnu/packages/telegram.scm | 207 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 gnu/packages/telegram.scm diff --git a/gnu/local.mk b/gnu/local.mk index 7d405c2462..747cbb1da7 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -534,6 +534,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/task-management.scm \ %D%/packages/tbb.scm \ %D%/packages/tcl.scm \ + %D%/packages/telegram.scm \ %D%/packages/telephony.scm \ %D%/packages/terminals.scm \ %D%/packages/terraform.scm \ diff --git a/gnu/packages/telegram.scm b/gnu/packages/telegram.scm new file mode 100644 index 0000000000..7339025d49 --- /dev/null +++ b/gnu/packages/telegram.scm @@ -0,0 +1,207 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Raghav Gururajan +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages telegram) + #:use-module (gnu packages) + #:use-module (gnu packages aidc) + #:use-module (gnu packages audio) + #:use-module (gnu packages base) + #:use-module (gnu packages check) + #:use-module (gnu packages cmake) + #:use-module (gnu packages compression) + #:use-module (gnu packages cpp) + #:use-module (gnu packages digest) + #:use-module (gnu packages fcitx) + #:use-module (gnu packages fcitx5) + #:use-module (gnu packages gcc) + #:use-module (gnu packages glib) + #:use-module (gnu packages gnome) + #:use-module (gnu packages gtk) + #:use-module (gnu packages image) + #:use-module (gnu packages kde-frameworks) + #:use-module (gnu packages language) + #:use-module (gnu packages libreoffice) + #:use-module (gnu packages linux) + #:use-module (gnu packages lxqt) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages pulseaudio) + #:use-module (gnu packages python) + #:use-module (gnu packages qt) + #:use-module (gnu packages telephony) + #:use-module (gnu packages tls) + #:use-module (gnu packages video) + #:use-module (gnu packages xiph) + #:use-module (gnu packages xorg) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix git-download) + #:use-module (guix build-system glib-or-gtk) + #:use-module (guix build-system qt)) + +(define-public telegram-desktop + (package + (name "telegram-desktop") + (version "2.5.1") + (source + (origin + (method git-fetch) + (uri + (git-reference + (url "https://github.com/telegramdesktop/tdesktop.git") + (commit + (string-append "v" version)) + (recursive? #t))) + (file-name + (git-file-name name version)) + (sha256 + (base32 "1qw9vaa482dbz97mzwjzmy3fw72s5bk3hyacyz98ms652xgld6js")))) + (build-system qt-build-system) + (arguments + `(#:tests? #f ; No target + #:imported-modules + (,@%qt-build-system-modules + (guix build glib-or-gtk-build-system)) + #:modules + ((guix build qt-build-system) + ((guix build glib-or-gtk-build-system) + #:prefix glib-or-gtk:) + (guix build utils)) + #:configure-flags + ;; Unique API-ID and API-HASH must obtained for each client application. + ;; Reference: https://core.telegram.org/api/obtaining_api_id + ;; The following API-ID and API-HASH are generated from my account. + ;; In case of ban/block, contact: rg@raghavgururajan.name + (list + "-DTDESKTOP_API_ID=2791056" + "-DTDESKTOP_API_HASH=582d6d0b44f7a2de949e99271fd8b3f2") + #:phases + (modify-phases %standard-phases + ;; Git checkouts are not writable by default, + ;; but the package writes to it. + (add-after 'unpack 'make-writable + (lambda _ + (for-each make-file-writable + (find-files ".")) + #t)) + (add-after 'make-writable 'remove-thirdparty + (lambda _ + (with-directory-excursion "Telegram/ThirdParty" + ;; [1] Keep SPMediaKeyTap, StatusNotifierItem, + ;; LibTgVoIP and rLottie. + ;; [2] SPMediaKeyTap and StatusNotifierItem are not available. + ;; [3] Telegram-Desktop uses custom fork of LibTgVoIP and rLottie, + ;; which are different from the ones available in Guix. + (for-each delete-file-recursively + (list + "Catch" + "GSL" + "QR" + "expected" + "fcitx-qt5" + "fcitx5-qt" + "hime" + "hunspell" + "libdbusmenu-qt" + ;; "libtgvoip" + "lz4" + "materialdecoration" + "minizip" + "nimf" + "qt5ct" + "range-v3" + ;; "rlottie" + "xxHash"))) + #t)) + (add-before 'configure 'patch-cxx-flags + (lambda _ + (substitute* "cmake/options_linux.cmake" + (("class-memaccess") + "all")) + #t)) + (add-after 'remove-thirdparty 'disable-emojis + (lambda _ + ;; FIXME: Emojis framework of Qt doesn't get loaded, + ;; so causes the application to crash upon launch. + (substitute* "Telegram/lib_ui/ui/emoji_config.cpp" + (("bool _unsupported = false") + "bool _unsupported = true") + ((" generateCache\\(\\);") + "//generateCache();")) + #t)) + (add-after 'install 'glib-or-gtk-compile-schemas + (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas)) + (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap + (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap))))) + (native-inputs + `(("cmake-shared" ,cmake-shared) + ("extra-cmake-modules" ,extra-cmake-modules) + ("gcc" ,gcc-9) + ("glib:bin" ,glib "bin") + ("gobject-introspection" ,gobject-introspection) + ("gtk+:bin" ,gtk+ "bin") + ("pkg-config" ,pkg-config) + ("python" ,python-wrapper) + ("qttools" ,qttools))) + (inputs + `(("alsa" ,alsa-lib) + ("catch" ,catch-framework2) + ("expected" ,libexpected) + ("fcitx-qt5" ,fcitx-qt5) + ("fcitx5-qt" ,fcitx5-qt) + ("ffmpeg" ,ffmpeg) + ("glib" ,glib) + ("gsl" ,gsl) + ("gtk+" ,gtk+) + ("hime" ,hime) + ("hunspell" ,hunspell) + ("iconv" ,libiconv) + ("libdbusmenu-qt" ,libdbusmenu-qt) + ("libjpeg" ,libjpeg-turbo) + ;; ("libtgvoip" ,libtgvoip) + ("lz4" ,lz4) + ("materialdecoration" ,materialdecoration) + ("minizip" ,minizip) + ("nimf" ,nimf) + ("openal" ,openal) + ("openssl" ,openssl) + ("opus" ,opus) + ("pulseaudio" ,pulseaudio) + ("qrcodegen" ,qrcodegen-cpp) + ("qt" ,qtbase) + ("qt5ct" ,qt5ct) + ("qtwayland" ,qtwayland) + ("range-v3" ,range-v3) + ;; ("rlottie" ,rlottie) + ("tg_owt" ,tg_owt) + ("x11" ,libx11) + ("xcb" ,libxcb) + ("xcb-keysyms" ,xcb-util-keysyms) + ("xxhash" ,xxhash) + ("zlib" ,zlib))) + (propagated-inputs + `(("dconf" ,dconf))) + (synopsis "Telegram Desktop") + (description "Tdesktop is the official desktop application for telegram +messenger.") + (home-page "https://desktop.telegram.org/") + (license + (list + ;; ThirdParty + license:lgpl2.1+ + ;; Others + license:gpl3+)))) -- 2.30.0