1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu packages telegram)
20 #:use-module (gnu packages)
21 #:use-module (gnu packages aidc)
22 #:use-module (gnu packages animation)
23 #:use-module (gnu packages assembly)
24 #:use-module (gnu packages audio)
25 #:use-module (gnu packages autotools)
26 #:use-module (gnu packages check)
27 #:use-module (gnu packages cmake)
28 #:use-module (gnu packages compression)
29 #:use-module (gnu packages cpp)
30 #:use-module (gnu packages digest)
31 #:use-module (gnu packages fcitx)
32 #:use-module (gnu packages fcitx5)
33 #:use-module (gnu packages glib)
34 #:use-module (gnu packages gnome)
35 #:use-module (gnu packages gnupg)
36 #:use-module (gnu packages gtk)
37 #:use-module (gnu packages image)
38 #:use-module (gnu packages jemalloc)
39 #:use-module (gnu packages kde-frameworks)
40 #:use-module (gnu packages language)
41 #:use-module (gnu packages libevent)
42 #:use-module (gnu packages libreoffice)
43 #:use-module (gnu packages linux)
44 #:use-module (gnu packages lxqt)
45 #:use-module (gnu packages lua)
46 #:use-module (gnu packages perl)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages protobuf)
49 #:use-module (gnu packages pulseaudio)
50 #:use-module (gnu packages python)
51 #:use-module (gnu packages python-check)
52 #:use-module (gnu packages python-web)
53 #:use-module (gnu packages python-xyz)
54 #:use-module (gnu packages qt)
55 #:use-module (gnu packages readline)
56 #:use-module (gnu packages textutils)
57 #:use-module (gnu packages telephony)
58 #:use-module (gnu packages tls)
59 #:use-module (gnu packages video)
60 #:use-module (gnu packages web)
61 #:use-module (gnu packages xiph)
62 #:use-module (gnu packages xorg)
63 #:use-module ((guix licenses) #:prefix license:)
64 #:use-module (guix packages)
65 #:use-module (guix gexp)
66 #:use-module (guix git-download)
67 #:use-module (guix build-system cmake)
68 #:use-module (guix build-system copy)
69 #:use-module (guix build-system glib-or-gtk)
70 #:use-module (guix build-system gnu)
71 #:use-module (guix build-system meson)
72 #:use-module (guix build-system python)
73 #:use-module (guix build-system qt))
75 (define %telegram-version "2.9.3")
77 (define libvpx-for-telegram-desktop
78 (let ((commit "5b63f0f821e94f8072eb483014cfc33b05978bb9")
83 (url "https://chromium.googlesource.com/webm/libvpx")
85 (file-name (git-file-name
86 "libvpx-for-telegram-desktop"
87 (git-version "1.9.0" revision commit)))
90 "1psvxaddihlw1k5n0anxif3qli6zyw2sa2ywn6mkb8six9myrp68")))))
92 (define libyuv-for-telegram-desktop
93 (let ((commit "ad890067f661dc747a975bc55ba3767fe30d4452")
98 (url "https://chromium.googlesource.com/libyuv/libyuv")
100 (file-name (git-file-name
101 "libyuv-for-telegram-desktop"
102 (git-version "0" revision commit)))
105 "01knnk4h247rq536097n9n3s3brxlbby3nv3ppdgsqfda3k159ll")))))
107 (define cmake-helpers-for-telegram-desktop
111 (url "https://github.com/desktop-app/cmake_helpers.git")
112 (commit "4d44d822e01b3b5fbec3ce824e01f56aa35d7f72")))
114 (git-file-name "cmake-helpers-for-telegram-desktop" %telegram-version))
117 "0h6cjiqy014h2mz90h1z5a7plb3ihbnds4bja8994ybr1dy3m7m5"))))
119 (define codegen-for-telegram-desktop
123 (url "https://github.com/desktop-app/codegen.git")
124 (commit "248614b49cd7d5aff69d75a737f2e35b79fbb119")))
126 (git-file-name "codegen-for-telegram-desktop" %telegram-version))
129 "00f7g2z6xmkbkrmi3q27hscjl44mg66wf9q0mz3rhy3jaa6cfdrk"))))
131 (define lib-base-for-telegram-desktop
135 (url "https://github.com/desktop-app/lib_base.git")
136 (commit "a23c05c44e4f01dc4428f4d75d4db98c59d313a6")))
138 (git-file-name "lib-base-for-telegram-desktop" %telegram-version))
141 "0vh5zgxwalmbnvz8lzlnba87ch8vnpmcz6nvf56w09f3nlxvvq78"))))
143 (define lib-crl-for-telegram-desktop
147 (url "https://github.com/desktop-app/lib_crl.git")
148 (commit "3ccf2ed5095442e5874bba8852cb7dc4efeae29f")))
150 (git-file-name "lib-crl-for-telegram-desktop" %telegram-version))
153 "11my7q54m4lvvlgma6pbdyjxi1cv1adk1gph2j50mh18sqlm8myz"))))
155 (define lib-lottie-for-telegram-desktop
159 (url "https://github.com/desktop-app/lib_lottie.git")
160 (commit "0770df009db7928df1d0cad0900dc5110106d229")))
162 (git-file-name "lib-lottie-for-telegram-desktop" %telegram-version))
165 "1gj56ymlbk5dnk82jw674808m511lv9dky8891a5wm4gp3pph5jb"))))
167 (define lib-qr-for-telegram-desktop
171 (url "https://github.com/desktop-app/lib_qr.git")
172 (commit "2b08c71c6edcfc3e31f7d7f518cc963493b6e189")))
174 (git-file-name "lib-qr-for-telegram-desktop" %telegram-version))
177 "05hrkmwgrczyjv87r507i2r7m1zr6k2i43mq3my0s6j4szr1rjq0"))))
179 (define lib-rlottie-for-telegram-desktop
183 (url "https://github.com/desktop-app/lib_rlottie.git")
184 (commit "0671bf70547381effcf442ec9618e04502a8adbc")))
186 (git-file-name "lib-rlottie-for-telegram-desktop" %telegram-version))
189 "05qnza7j15356s8jq16pkbyp4zr586lssmd86lz5jq23lcb3raxv"))))
191 (define lib-rpl-for-telegram-desktop
195 (url "https://github.com/desktop-app/lib_rpl.git")
196 (commit "df721be3fa14a27dfc230d2e3c42bb1a7c9d0617")))
198 (git-file-name "lib-rpl-for-telegram-desktop" %telegram-version))
201 "15fnv3ssn7rn5d0j52gggdvyqc2wm464678dj7v2x9h8lka2jjxn"))))
203 (define lib-spellcheck-for-telegram-desktop
207 (url "https://github.com/desktop-app/lib_spellcheck.git")
208 (commit "68c9b788958904aea7de79f986a0f82ec8c5b094")))
210 (git-file-name "lib-spellcheck-for-telegram-desktop" %telegram-version))
213 "0d8s4wwk6fxf536mhzq2vb9qw3j0m8nqia7ylvvpsbc4kh09dadn"))))
215 (define lib-storage-for-telegram-desktop
219 (url "https://github.com/desktop-app/lib_storage.git")
220 (commit "403df6c4a29562bd417c92d410e49819f5a48cc1")))
222 (git-file-name "lib-storage-for-telegram-desktop" %telegram-version))
225 "1zxvzfrxbj4d395fzyb5pm9wn3n8jyimxx88cyqjcdd46sx4h7r5"))))
227 (define lib-tl-for-telegram-desktop
231 (url "https://github.com/desktop-app/lib_tl.git")
232 (commit "45faed44e7f4d11fec79b7a70e4a35dc91ef3fdb")))
234 (git-file-name "lib-tl-for-telegram-desktop" %telegram-version))
237 "0h43xvzklda02494d466jp52hl8c1kmav9f12dyld10dpf1w6c7m"))))
239 (define lib-ui-for-telegram-desktop
243 (url "https://github.com/desktop-app/lib_ui.git")
244 (commit "1b590f9e16eb9571a039f072d6fea66c607e419f")))
246 (git-file-name "lib-ui-for-telegram-desktop" %telegram-version))
249 "0ighyhfp29h9h8c7vr70pnhcv2xnsr9ln084pssn8hb5z4pmb62f"))))
251 (define lib-waylandshells-for-telegram-desktop
255 (url "https://github.com/desktop-app/lib_waylandshells.git")
256 (commit "59b0ee55a68976d27f1bf7cec0e11d5939e185e7")))
258 (git-file-name "lib-waylandshells-for-telegram-desktop" %telegram-version))
261 "0l2xrpc5mvvdlsj333pmkgfvn9wi1ijfdaaz8skfnw9icw52faaf"))))
263 (define lib-webrtc-for-telegram-desktop
267 (url "https://github.com/desktop-app/lib_webrtc.git")
268 (commit "ef49f953f12b112008a094a719f40939aaf39db4")))
270 (git-file-name "lib-webrtc-for-telegram-desktop" %telegram-version))
273 "15k4xs3462p3ddp5cn9im3nvdiaijmxir8wxsf5yrj70ghy26ibw"))))
275 (define lib-webview-for-telegram-desktop
279 (url "https://github.com/desktop-app/lib_webview.git")
280 (commit "e06427c624515485774e2e2181d4afeb05ad5a67")))
282 (git-file-name "lib-webview-for-telegram-desktop" %telegram-version))
285 "148z7xzfscynwwwqssdsd97npax6yn8zrd64xw8qzbwff2g2r7k4"))))
287 (define tgcalls-for-telegram-desktop
291 (url "https://github.com/TelegramMessenger/tgcalls.git")
292 (commit "81e97fa52e25b7775b62ce07bb653533d81e91b3")))
294 (git-file-name "tgcalls-for-telegram-desktop" %telegram-version))
297 "0fvad87hyxli83xn19mgf8jjrrh6y6iaig14pckpbkg33vf4wqkj"))))
299 (define-public webrtc-for-telegram-desktop
300 (let ((commit "91d836dc84a16584c6ac52b36c04c0de504d9c34")
304 (name "webrtc-for-telegram-desktop")
306 (git-version "0" revision commit))
312 (url "https://github.com/desktop-app/tg_owt.git")
315 (git-file-name name version))
317 (base32 "0plwdp6xgxi27hif5j7kpq425cidxyxbbga3z2f64dsninwy5p1x"))
318 (modules '((guix build utils)
324 '( ;; Custom forks which are incompatible with the ones in Guix.
325 "abseil-cpp" "libsrtp" "openh264" "rnnoise"
326 ;; Not available in Guix.
328 ;; Has cmake support files for libvpx input.
330 (with-directory-excursion "src/third_party"
331 (for-each delete-file-recursively
332 (lset-difference string=?
334 (cons* "." ".." keep)))))))))
335 (build-system cmake-build-system)
338 #:tests? #f ; No target
339 #:configure-flags #~(list "-DCMAKE_C_FLAGS=-fPIC"
340 "-DCMAKE_CXX_FLAGS=-fPIC")
342 #~(modify-phases %standard-phases
343 (add-after 'unpack 'copy-inputs
345 (let* ((third-party (string-append (getcwd) "/src/third_party"))
346 (libvpx-to (string-append third-party
347 "/libvpx/source/libvpx"))
348 (libyuv-to (string-append third-party "/libyuv")))
349 (copy-recursively #$libvpx-for-telegram-desktop libvpx-to)
350 (copy-recursively #$libyuv-for-telegram-desktop
352 (native-inputs (list perl pkg-config python-wrapper yasm))
370 (synopsis "WebRTC support for Telegram Desktop")
371 (description "WebRTC-for-Telegram-Desktop is a custom WebRTC fork by
372 Telegram project, for its use in telegram desktop client.")
373 (home-page "https://github.com/desktop-app/tg_owt")
379 (license:non-copyleft "file:///src/third_party/libyuv/LICENSE")
383 (license:non-copyleft "file:///src/third_party/pffft/LICENSE")
386 ;; LibSRTP, LibVPx, UsrSCTP and Others
389 (define-public rlottie-for-telegram-desktop
390 (let ((commit "cbd43984ebdf783e94c8303c41385bf82aa36d5b")
396 (git-version "0.0.1" revision commit))
402 (url "https://github.com/desktop-app/rlottie.git")
405 (git-file-name "rlottie-for-telegram-desktop" version))
407 (base32 "1lxpbgbhps9rmck036mgmiknqrzpjxpas8n7qxykv6pwzn0c8n0c"))))
415 (modify-phases %standard-phases
416 (add-after 'unpack 'patch-cxx-flags
418 (substitute* "meson.build"
423 (define-public libtgvoip-for-telegram-desktop
424 (let ((commit "13a5fcb16b04472d808ce122abd695dbf5d206cd")
430 (git-version "2.4.4" revision commit))
436 (url "https://github.com/telegramdesktop/libtgvoip.git")
439 (git-file-name "libtgvoip-for-telegram-desktop" version))
441 (base32 "12p6s7vxkf1gh1spdckkdxrx7bjzw881ds9bky7l5fw751cwb3xd"))))
446 "--disable-dsp" ; FIXME
447 "--enable-audio-callback"
451 (modify-phases %standard-phases
452 (add-after 'unpack 'patch-linkers
454 (substitute* "Makefile.am"
455 (("\\$\\(CRYPTO_LIBS\\) \\$\\(OPUS_LIBS\\)")
456 "$(CRYPTO_LIBS) $(OPUS_LIBS) $(ALSA_LIBS) $(PULSE_LIBS)"))
457 (substitute* "tgvoip.pc.in"
459 "libcrypto opus alsa libpulse"))
462 (list autoconf automake libtool pkg-config))))))
464 (define-public telegram-desktop
466 (name "telegram-desktop")
467 (version %telegram-version)
473 (url "https://github.com/telegramdesktop/tdesktop.git")
475 (string-append "v" version))))
477 (git-file-name name version))
479 (base32 "0dzf1y3xhqvizg29bd1kya48cjbkq073d2x10ynwcmmx396l4nd8"))
480 (modules '((guix build utils)
486 '( ;; Not available in Guix.
487 "SPMediaKeyTap" "statusnotifieritem" "tgcalls")))
488 (with-directory-excursion "Telegram/ThirdParty"
489 (for-each delete-file-recursively
490 (lset-difference string=?
492 (cons* "." ".." keep)))))))))
493 (build-system qt-build-system)
495 (list #:tests? #f ; No target
497 `(,@%qt-build-system-modules
498 (guix build glib-or-gtk-build-system))
500 '((guix build qt-build-system)
501 ((guix build glib-or-gtk-build-system)
502 #:prefix glib-or-gtk:)
507 ;; Client applications must provide their own API-ID and API-HASH,
508 ;; see also <https://core.telegram.org/api/obtaining_api_id>.
509 ;; In case, that the credentials below fail to work, contact
510 ;; Raghav Gururajan <rg@raghavgururajan.name>
511 "-DTDESKTOP_API_ID=2791056"
512 "-DTDESKTOP_API_HASH=582d6d0b44f7a2de949e99271fd8b3f2"
513 ;; Disable WebkitGTK support as it fails to link
514 "-DDESKTOP_APP_DISABLE_WEBKITGTK=ON"
515 ;; Use bundled fonts as fallback.
516 "-DDESKTOP_APP_USE_PACKAGED_FONTS=OFF")
518 #~(modify-phases %standard-phases
519 (add-after 'unpack 'make-writable
521 (for-each make-file-writable (find-files "."))))
522 (add-after 'make-writable 'copy-inputs
527 (copy-recursively src dst)
528 (for-each make-file-writable (find-files dst))))
529 '(("cmake" #$cmake-helpers-for-telegram-desktop)
530 ("Telegram/codegen" #$codegen-for-telegram-desktop)
531 ("Telegram/lib_base" #$lib-base-for-telegram-desktop)
532 ("Telegram/lib_crl" #$lib-crl-for-telegram-desktop)
533 ("Telegram/lib_lottie" #$lib-lottie-for-telegram-desktop)
534 ("Telegram/lib_qr" #$lib-qr-for-telegram-desktop)
535 ("Telegram/lib_rlottie" #$lib-rlottie-for-telegram-desktop)
536 ("Telegram/lib_rpl" #$lib-rpl-for-telegram-desktop)
537 ("Telegram/lib_spellcheck" #$lib-spellcheck-for-telegram-desktop)
538 ("Telegram/lib_storage" #$lib-storage-for-telegram-desktop)
539 ("Telegram/lib_tl" #$lib-tl-for-telegram-desktop)
540 ("Telegram/lib_ui" #$lib-ui-for-telegram-desktop)
541 ("Telegram/lib_waylandshells" #$lib-waylandshells-for-telegram-desktop)
542 ("Telegram/lib_webrtc" #$lib-webrtc-for-telegram-desktop)
543 ("Telegram/lib_webview" #$lib-webview-for-telegram-desktop)
544 ("Telegram/ThirdParty/tgcalls" #$tgcalls-for-telegram-desktop)))))
545 (add-before 'configure 'patch-cxx-flags
547 (substitute* "cmake/options_linux.cmake" (("class-memaccess") "all"))))
548 (add-after 'install 'glib-or-gtk-compile-schemas
549 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
550 (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
551 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
577 libtgvoip-for-telegram-desktop
593 rlottie-for-telegram-desktop
595 webrtc-for-telegram-desktop
601 (propagated-inputs (list dconf))
602 (synopsis "Telegram Desktop")
603 (description "Telegram desktop is the official desktop version of the
604 Telegram instant messenger.")
605 (home-page "https://desktop.telegram.org/")
613 (define-public tl-parser
614 (let ((commit "1933e76f8f4fb74311be723b432e4c56e3a5ec06")
619 (git-version "0" revision commit))
625 (url "https://github.com/vysheng/tl-parser.git")
628 (git-file-name name version))
630 (base32 "13cwi247kajzpkbl86hnwmn1sn2h6rqndz6khajbqj0mlw9mv4hq"))))
631 (build-system cmake-build-system)
633 `(#:tests? #f ; No target
635 ((guix build copy-build-system)
636 ,@%cmake-build-system-modules)
638 (((guix build copy-build-system)
640 (guix build cmake-build-system)
643 (modify-phases %standard-phases
646 (apply (assoc-ref copy:%standard-phases 'install)
649 #:include ("tl-parser"))
650 ("../source" "include/tl-parser"
651 #:include-regexp ("\\.h$")))
653 (synopsis "Parse tl scheme to tlo")
654 (description "TL-Parser is a tl scheme to tlo file parser. It was
655 formerly a part of telegram-cli, but now being maintained separately.")
656 (home-page "https://github.com/vysheng/tl-parser")
657 (license license:gpl2+))))
660 (let ((commit "ffb04caca71de0cddf28cd33a4575922900a59ed")
665 (git-version "2.0.1" revision commit))
671 (url "https://github.com/vysheng/tgl.git")
674 (git-file-name name version))
676 (base32 "0cf5s7ygslb5klg1qv9qdc3hivhspmvh3zkacyyhd2yyikb5p0f9"))))
677 (build-system gnu-build-system)
679 `(#:tests? #f ; No target
681 ((guix build copy-build-system)
682 ,@%gnu-build-system-modules)
684 (((guix build copy-build-system)
686 (guix build gnu-build-system)
690 ;; Use gcrypt instead of openssl.
692 ;; Enable extended queries system.
694 ;; Include libevent-based net and timers.
697 (modify-phases %standard-phases
698 (add-after 'unpack 'trigger-bootstrap
700 (delete-file "configure")
702 (add-after 'trigger-bootstrap 'patch-tl-parser
704 (delete-file "Makefile.tl-parser")
705 (substitute* "Makefile.in"
706 (("include \\$\\{srcdir\\}/Makefile\\.tl-parser")
708 (("\\$\\{EXE\\}/tl-parser")
713 (apply (assoc-ref copy:%standard-phases 'install)
717 #:include-regexp ("\\.h$"))
721 (list autoconf automake libtool pkg-config))
723 (list libevent libgcrypt tl-parser zlib))
724 (synopsis "Telegram Library")
725 (description "TGL is the telegram library for telegram-cli.")
726 (home-page "https://github.com/vysheng/tgl")
727 (license license:lgpl2.1+))))
729 (define-public telegram-cli
730 (let ((commit "6547c0b21b977b327b3c5e8142963f4bc246187a")
733 (name "telegram-cli")
735 (git-version "1.3.1" revision commit))
741 (url "https://github.com/vysheng/tg.git")
744 (git-file-name name version))
746 (base32 "0c1w7jgska71jjbvg1y09v52549pwa4zkdjly18yxywn7gayd2p6"))))
747 (build-system gnu-build-system)
749 `(#:tests? #f ; No target
751 ((guix build copy-build-system)
752 ,@%gnu-build-system-modules)
754 (((guix build copy-build-system)
756 (guix build gnu-build-system)
760 ;; Use gcrypt instead of openssl.
763 (modify-phases %standard-phases
764 (add-after 'unpack 'trigger-bootstrap
766 (delete-file "configure")
768 (add-after 'trigger-bootstrap 'patch-tgl-and-tlparser
769 (lambda* (#:key inputs #:allow-other-keys)
770 (for-each delete-file
773 "Makefile.tl-parser"))
774 (substitute* "Makefile.in"
775 (("include \\$\\{srcdir\\}/Makefile\\.tl-parser")
777 (("include \\$\\{srcdir\\}/Makefile\\.tgl")
779 (("-I\\$\\{srcdir\\}/tgl")
780 (string-append "-I" (assoc-ref inputs "tgl")
783 (string-append "AUTO=" (assoc-ref inputs "tgl")
784 "/include/tgl/auto"))
786 (string-append "LIB=" (assoc-ref inputs "tgl")
791 (apply (assoc-ref copy:%standard-phases 'install)
794 ("." "etc/telegram-cli"
795 #:include-regexp ("\\.pub$")
796 #:exclude ("tg-server.pub")))
799 (list autoconf automake libtool pkg-config))
813 (synopsis "Telegram Messenger CLI")
814 (description "TG is the command-line interface for Telegram Messenger.")
815 (home-page "https://github.com/vysheng/tg")
816 (license license:gpl2+))))
827 (url "https://github.com/erayerdin/tgcli")
828 (commit (string-append "v" version))))
830 (git-file-name name version))
832 (base32 "082zim7rh4r8qyscqimjh2sz7998vv9j1i2y2wwz2rgrlhkhly5r"))))
833 (build-system python-build-system)
836 (modify-phases %standard-phases
837 ;; Test requirements referes to specific versions of packages,
838 ;; which are too old. So we patch them to refer to any later versions.
839 (add-after 'unpack 'patch-test-requirements
841 (substitute* "dev.requirements.txt"
844 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
846 (add-installed-pythonpath inputs outputs)
847 (invoke "pytest" "tests")))))))
849 `(("coveralls" ,python-coveralls)
850 ("pytest" ,python-pytest)
851 ("pytest-click" ,python-pytest-click)
852 ("pytest-cov" ,python-pytest-cov)
853 ("mkdocs" ,python-mkdocs)
854 ("mkdocs-material" ,python-mkdocs-material)
855 ("requests-mock" ,python-requests-mock)))
857 `(("click" ,python-click)
858 ("colorful" ,python-colorful)
859 ("requests" ,python-requests)
860 ("yaspin" ,python-yaspin)))
861 (home-page "https://tgcli.readthedocs.io")
862 (synopsis "Telegram Terminal Application")
863 (description "TgCli is a telegram client to automate repetitive tasks.")
864 (license license:asl2.0)))