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 base)
27 #:use-module (gnu packages check)
28 #:use-module (gnu packages cmake)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages cpp)
31 #:use-module (gnu packages digest)
32 #:use-module (gnu packages fcitx)
33 #:use-module (gnu packages fcitx5)
34 #:use-module (gnu packages gcc)
35 #:use-module (gnu packages glib)
36 #:use-module (gnu packages gnome)
37 #:use-module (gnu packages gnupg)
38 #:use-module (gnu packages gtk)
39 #:use-module (gnu packages image)
40 #:use-module (gnu packages kde-frameworks)
41 #:use-module (gnu packages language)
42 #:use-module (gnu packages libevent)
43 #:use-module (gnu packages libreoffice)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages lxqt)
46 #:use-module (gnu packages lua)
47 #:use-module (gnu packages perl)
48 #:use-module (gnu packages pkg-config)
49 #:use-module (gnu packages protobuf)
50 #:use-module (gnu packages pulseaudio)
51 #:use-module (gnu packages python)
52 #:use-module (gnu packages qt)
53 #:use-module (gnu packages readline)
54 #:use-module (gnu packages textutils)
55 #:use-module (gnu packages telephony)
56 #:use-module (gnu packages tls)
57 #:use-module (gnu packages video)
58 #:use-module (gnu packages web)
59 #:use-module (gnu packages xiph)
60 #:use-module (gnu packages xorg)
61 #:use-module ((guix licenses) #:prefix license:)
62 #:use-module (guix packages)
63 #:use-module (guix git-download)
64 #:use-module (guix build-system cmake)
65 #:use-module (guix build-system copy)
66 #:use-module (guix build-system glib-or-gtk)
67 #:use-module (guix build-system gnu)
68 #:use-module (guix build-system meson)
69 #:use-module (guix build-system qt))
71 (define-public webrtc-for-telegram-desktop
72 (let ((commit "a19877363082da634a3c851a4698376504d2eaee")
76 (name "webrtc-for-telegram-desktop")
78 (git-version "0" revision commit))
84 (url "https://github.com/desktop-app/tg_owt.git")
87 (git-file-name name version))
89 (base32 "0961zm1m1mc2kh54dx5ax95q8sw13impvpjvg9jv12bmfkgm17wr"))
90 (modules '((guix build utils)
96 '( ;; Custom forks which are incompatible with the ones in Guix.
97 "abseil-cpp" "libsrtp" "openh264" "rnnoise"
98 ;; Not available in Guix.
100 ;; Has cmake support files for libvpx input.
102 (with-directory-excursion "src/third_party"
103 (for-each delete-file-recursively
104 (lset-difference string=?
106 (cons* "." ".." keep))))
108 (build-system cmake-build-system)
110 `(#:tests? #f ; No target
113 "-DCMAKE_C_FLAGS=-fPIC"
114 "-DCMAKE_CXX_FLAGS=-fPIC")
116 (modify-phases %standard-phases
117 (add-after 'unpack 'copy-inputs
118 (lambda* (#:key inputs outputs #:allow-other-keys)
119 (let* ((libvpx-from (assoc-ref inputs "libvpx"))
120 (libyuv-from (assoc-ref inputs "libyuv"))
121 (libvpx-to (string-append (getcwd)
122 "/src/third_party/libvpx/source/libvpx"))
123 (libyuv-to (string-append (getcwd)
124 "/src/third_party/libyuv")))
125 (copy-recursively libvpx-from libvpx-to)
126 (copy-recursively libyuv-from libyuv-to))
129 `(("pkg-config" ,pkg-config)
130 ("python" ,python-wrapper)
135 ("libjpeg" ,libjpeg-turbo)
141 (url "https://chromium.googlesource.com/webm/libvpx")
142 (commit "5b63f0f821e94f8072eb483014cfc33b05978bb9")))
144 (git-file-name "libvpx-for-webrtc-for-telegram-desktop" version))
146 (base32 "1psvxaddihlw1k5n0anxif3qli6zyw2sa2ywn6mkb8six9myrp68"))))
152 (url "https://chromium.googlesource.com/libyuv/libyuv")
153 (commit "ad890067f661dc747a975bc55ba3767fe30d4452")))
155 (git-file-name "libyuv-for-webrtc-for-telegram-desktop" version))
157 (base32 "01knnk4h247rq536097n9n3s3brxlbby3nv3ppdgsqfda3k159ll"))))
160 ("protobuf" ,protobuf)
161 ("pulseaudio" ,pulseaudio)
165 (synopsis "WebRTC support for Telegram Desktop")
166 (description "WebRTC-for-Telegram-Desktop is a custom WebRTC fork by
167 Telegram project, for its use in telegram desktop client.")
168 (home-page "https://github.com/desktop-app/tg_owt")
174 (license:non-copyleft "file:///src/third_party/libyuv/LICENSE")
178 (license:non-copyleft "file:///src/third_party/pffft/LICENSE")
181 ;; LibSRTP, LibVPx, UsrSCTP and Others
184 (define-public rlottie-for-telegram-desktop
185 (let ((commit "cbd43984ebdf783e94c8303c41385bf82aa36d5b")
191 (git-version "0.0.1" revision commit))
197 (url "https://github.com/desktop-app/rlottie.git")
200 (git-file-name "rlottie-for-telegram-desktop" version))
202 (base32 "1lxpbgbhps9rmck036mgmiknqrzpjxpas8n7qxykv6pwzn0c8n0c"))))
210 (modify-phases %standard-phases
211 (add-after 'unpack 'patch-cxx-flags
213 (substitute* "meson.build"
218 (define-public libtgvoip-for-telegram-desktop
219 (let ((commit "13a5fcb16b04472d808ce122abd695dbf5d206cd")
225 (git-version "2.4.4" revision commit))
231 (url "https://github.com/telegramdesktop/libtgvoip.git")
234 (git-file-name "libtgvoip-for-telegram-desktop" version))
236 (base32 "12p6s7vxkf1gh1spdckkdxrx7bjzw881ds9bky7l5fw751cwb3xd"))))
241 "--disable-dsp" ; FIXME
242 "--enable-audio-callback"
246 (modify-phases %standard-phases
247 (add-after 'unpack 'patch-linkers
249 (substitute* "Makefile.am"
250 (("\\$\\(CRYPTO_LIBS\\) \\$\\(OPUS_LIBS\\)")
251 "$(CRYPTO_LIBS) $(OPUS_LIBS) $(ALSA_LIBS) $(PULSE_LIBS)"))
252 (substitute* "tgvoip.pc.in"
254 "libcrypto opus alsa libpulse"))
257 `(("autoconf" ,autoconf)
258 ("automake" ,automake)
260 ("pkg-config" ,pkg-config)))))))
262 (define-public telegram-desktop
264 (name "telegram-desktop")
271 (url "https://github.com/telegramdesktop/tdesktop.git")
273 (string-append "v" version))))
275 (git-file-name name version))
277 (base32 "1lqs06scqvzg37a2py8jk7nnlvk42jjifcpnhdd5rgd5biw70nyx"))
278 (modules '((guix build utils)
284 '( ;; Not available in Guix.
285 "SPMediaKeyTap" "statusnotifieritem" "tgcalls")))
286 (with-directory-excursion "Telegram/ThirdParty"
287 (for-each delete-file-recursively
288 (lset-difference string=?
290 (cons* "." ".." keep))))
292 (build-system qt-build-system)
294 `(#:tests? #f ; No target
296 (,@%qt-build-system-modules
297 (guix build glib-or-gtk-build-system))
299 ((guix build qt-build-system)
300 ((guix build glib-or-gtk-build-system)
301 #:prefix glib-or-gtk:)
306 ;; Client applications must provide their own API-ID and API-HASH,
307 ;; see also <https://core.telegram.org/api/obtaining_api_id>.
308 ;; In case, that the credentials below fail to work, contact
309 ;; Raghav Gururajan <rg@raghavgururajan.name>
310 "-DTDESKTOP_API_ID=2791056"
311 "-DTDESKTOP_API_HASH=582d6d0b44f7a2de949e99271fd8b3f2"
312 ;; Use bundled fonts as fallback.
313 "-DDESKTOP_APP_USE_PACKAGED_FONTS=OFF")
315 (modify-phases %standard-phases
316 (add-after 'unpack 'make-writable
318 (for-each make-file-writable (find-files "."))
320 (add-after 'make-writable 'copy-inputs
321 (lambda* (#:key inputs outputs #:allow-other-keys)
325 (copy-recursively src dst)
326 (for-each make-file-writable (find-files dst))))
327 `(("cmake" ,(assoc-ref inputs "cmake-helpers"))
328 ("Telegram/codegen" ,(assoc-ref inputs "codegen-source"))
329 ("Telegram/lib_base" ,(assoc-ref inputs "lib-base-source"))
330 ("Telegram/lib_crl" ,(assoc-ref inputs "lib-crl-source"))
331 ("Telegram/lib_lottie"
332 ,(assoc-ref inputs "lib-lottie-source"))
333 ("Telegram/lib_qr" ,(assoc-ref inputs "lib-qr-source"))
334 ("Telegram/lib_rlottie"
335 ,(assoc-ref inputs "lib-rlottie-source"))
336 ("Telegram/lib_rpl" ,(assoc-ref inputs "lib-rpl-source"))
337 ("Telegram/lib_spellcheck"
338 ,(assoc-ref inputs "lib-spellcheck-source"))
339 ("Telegram/lib_storage"
340 ,(assoc-ref inputs "lib-storage-source"))
341 ("Telegram/lib_tl" ,(assoc-ref inputs "lib-tl-source"))
342 ("Telegram/lib_ui" ,(assoc-ref inputs "lib-ui-source"))
343 ("Telegram/lib_webrtc" ,(assoc-ref inputs "lib-webrtc-source"))
344 ("Telegram/ThirdParty/tgcalls"
345 ,(assoc-ref inputs "tgcalls-source"))))
347 (add-before 'configure 'patch-cxx-flags
349 (substitute* "cmake/options_linux.cmake"
350 (("class-memaccess") "all"))
352 (add-after 'install 'glib-or-gtk-compile-schemas
353 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
354 (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
355 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
362 (url "https://github.com/desktop-app/cmake_helpers.git")
363 (commit "695fabda6830b58bdc02d09db70531d5dececcd0")))
365 (git-file-name "cmake-helpers-for-telegram-desktop" version))
367 (base32 "1j3ppgfmihcjl22w5jk8jhwif10i9wbycq5zqnssn6pnhnj7di5i"))))
368 ("cmake-shared" ,cmake-shared)
369 ("extra-cmake-modules" ,extra-cmake-modules)
371 ("glib:bin" ,glib "bin")
372 ("gobject-introspection" ,gobject-introspection)
373 ("gtk+:bin" ,gtk+ "bin")
374 ("pkg-config" ,pkg-config)
375 ("python" ,python-wrapper)
376 ("qttools" ,qttools)))
380 ("catch" ,catch-framework2)
386 (url "https://github.com/desktop-app/codegen.git")
387 (commit "127968de8129e8ccfa6ac50721c70415a5a087c3")))
389 (git-file-name "codegen" version))
391 (base32 "036hzjrsk134ky62192nra43rsln5kh5gz20q1920s922661zky2"))))
392 ("expected" ,libexpected)
393 ("fcitx-qt5" ,fcitx-qt5)
394 ("fcitx5-qt" ,fcitx5-qt)
399 ("hunspell" ,hunspell)
401 ("kwayland" ,kwayland)
407 (url "https://github.com/desktop-app/lib_base.git")
408 (commit "f1e4168081428fa451d2f50eee7b1c448268c43a")))
410 (git-file-name "lib-base-for-telegram-desktop" version))
412 (base32 "0piqp7llwi7sfy4c15g0p8ihr90rz1qps6q5fkl1iasrf5ysw8qc"))))
418 (url "https://github.com/desktop-app/lib_crl.git")
419 (commit "16150bf71d79382738114b913f137ec1a1a7630c")))
421 (git-file-name "lib-crl-for-telegram-desktop" version))
423 (base32 "0qhagdr26aqb9w7wnchcmk1j7ln28x3wbkkkm06b8h0mybksbj7q"))))
429 (url "https://github.com/desktop-app/lib_lottie.git")
430 (commit "fb40f379d82ffa1fc7506e9a8dddcf48847715ae")))
432 (git-file-name "lib-lottie-for-telegram-desktop" version))
434 (base32 "1vq0mqxcrrv7akcqk9cl4mm61zw6dcfmy8adl0pcp49kynm64saw"))))
440 (url "https://github.com/desktop-app/lib_qr.git")
441 (commit "92ce41a690a463eb462089a4eb1e51e019308018")))
443 (git-file-name "lib-qr-for-telegram-desktop" version))
445 (base32 "182939nv7xs9b3bgah3gl5y9hx5r59mabd2jw3z6717vc96qi2pj"))))
446 ("lib-rlottie-source"
451 (url "https://github.com/desktop-app/lib_rlottie.git")
452 (commit "0671bf70547381effcf442ec9618e04502a8adbc")))
454 (git-file-name "lib-rlottie-for-telegram-desktop" version))
456 (base32 "05qnza7j15356s8jq16pkbyp4zr586lssmd86lz5jq23lcb3raxv"))))
462 (url "https://github.com/desktop-app/lib_rpl.git")
463 (commit "e1b96399d9031c4ef0354631e6bb375029d29d9f")))
465 (git-file-name "lib-rpl-for-telegram-desktop" version))
467 (base32 "1wvqazljd2kq1fxlj250jhjrig529499bym9p81dx33kh1l9dgss"))))
468 ("lib-spellcheck-source"
473 (url "https://github.com/desktop-app/lib_spellcheck.git")
474 (commit "1b540b38ed78e9a3cba93e9ba4ce4525ab692277")))
476 (git-file-name "lib-spellcheck-for-telegram-desktop" version))
478 (base32 "0a7042h5zrdvgs7v153ral2dh1zj84di5yjcmgcry5k4s1im9di7"))))
479 ("lib-storage-source"
484 (url "https://github.com/desktop-app/lib_storage.git")
485 (commit "cbe51722b73cfa9ff27bd59294b08aa5ee33c936")))
487 (git-file-name "lib-storage-for-telegram-desktop" version))
489 (base32 "045l5xsyagyz17gbhmmvl2miss4nb92p0dmza7yfs9pkg9gs0f87"))))
495 (url "https://github.com/desktop-app/lib_tl.git")
496 (commit "404c83d77e5edb8a39f8e9f56a6340960fe5070e")))
498 (git-file-name "lib-tl-for-telegram-desktop" version))
500 (base32 "1k34nkvvcjqw5q81n1qmklid60cvzjk4lmn9qjimk437m6wbii7f"))))
506 (url "https://github.com/desktop-app/lib_ui.git")
507 (commit "e14bc4681d69c1b538b8c5af51501077ae5a8a86")))
509 (git-file-name "lib-ui-for-telegram-desktop" version))
511 (base32 "04b1x4bswk3bxqrwpv5g7w4frkprrwf0px6aibh6z4drinv08wsv"))))
517 (url "https://github.com/desktop-app/lib_webrtc.git")
518 (commit "60d5c43daf882a6c03944a3e6198b5f35b654a0e")))
520 (git-file-name "lib-webrtc-for-telegram-desktop" version))
522 (base32 "0mxmbw8i37axllg9h976p6np2gcfyci6xwwl9hc9mhs49vwwsw5s"))))
523 ("libdbusmenu-qt" ,libdbusmenu-qt)
524 ("libjpeg" ,libjpeg-turbo)
525 ("libtgvoip" ,libtgvoip-for-telegram-desktop)
527 ("materialdecoration" ,materialdecoration)
533 ("pulseaudio" ,pulseaudio)
534 ("qrcodegen" ,qrcodegen-cpp)
537 ("qtimageformats" ,qtimageformats)
538 ("qtwayland" ,qtwayland)
539 ("range-v3" ,range-v3)
540 ("rlottie" ,rlottie-for-telegram-desktop)
546 (url "https://github.com/TelegramMessenger/tgcalls.git")
547 (commit "71addf5b41cb6bb6844f75e977edae0020938930")))
549 (git-file-name "tgcalls-for-telegram-desktop" version))
551 (base32 "1zrjxf03n3ad8b95gwjarmq4gj5i5cwhlg93qcjv2232kksh29iy"))))
552 ("webrtc" ,webrtc-for-telegram-desktop)
555 ("xcb-keysyms" ,xcb-util-keysyms)
560 (synopsis "Telegram Desktop")
561 (description "Telegram desktop is the official desktop version of the
562 Telegram instant messager.")
563 (home-page "https://desktop.telegram.org/")
571 (define-public tl-parser
572 (let ((commit "1933e76f8f4fb74311be723b432e4c56e3a5ec06")
577 (git-version "0" revision commit))
583 (url "https://github.com/vysheng/tl-parser.git")
586 (git-file-name name version))
588 (base32 "13cwi247kajzpkbl86hnwmn1sn2h6rqndz6khajbqj0mlw9mv4hq"))))
589 (build-system cmake-build-system)
591 `(#:tests? #f ; No target
593 ((guix build copy-build-system)
594 ,@%cmake-build-system-modules)
596 (((guix build copy-build-system)
598 (guix build cmake-build-system)
601 (modify-phases %standard-phases
604 (apply (assoc-ref copy:%standard-phases 'install)
607 #:include ("tl-parser"))
608 ("../source" "include/tl-parser"
609 #:include-regexp ("\\.h$")))
611 (synopsis "Parse tl scheme to tlo")
612 (description "TL-Parser is a tl scheme to tlo file parser. It was formely
613 a part of telegram-cli, but now being maintained separately.")
614 (home-page "https://github.com/vysheng/tl-parser")
615 (license license:gpl2+))))
618 (let ((commit "ffb04caca71de0cddf28cd33a4575922900a59ed")
623 (git-version "2.0.1" revision commit))
629 (url "https://github.com/vysheng/tgl.git")
632 (git-file-name name version))
634 (base32 "0cf5s7ygslb5klg1qv9qdc3hivhspmvh3zkacyyhd2yyikb5p0f9"))))
635 (build-system gnu-build-system)
637 `(#:tests? #f ; No target
639 ((guix build copy-build-system)
640 ,@%gnu-build-system-modules)
642 (((guix build copy-build-system)
644 (guix build gnu-build-system)
648 ;; Use gcrypt instead of openssl.
650 ;; Enable extended queries system.
652 ;; Include libevent-based net and timers.
655 (modify-phases %standard-phases
656 (add-after 'unpack 'trigger-bootstrap
658 (delete-file "configure")
660 (add-after 'trigger-bootstrap 'patch-tl-parser
662 (delete-file "Makefile.tl-parser")
663 (substitute* "Makefile.in"
664 (("include \\$\\{srcdir\\}/Makefile\\.tl-parser")
666 (("\\$\\{EXE\\}/tl-parser")
671 (apply (assoc-ref copy:%standard-phases 'install)
675 #:include-regexp ("\\.h$"))
679 `(("autoconf" ,autoconf)
680 ("automake" ,automake)
682 ("pkg-config" ,pkg-config)))
684 `(("libevent" ,libevent)
685 ("libgcrypt" ,libgcrypt)
686 ("tl-parser" ,tl-parser)
688 (synopsis "Telegram Library")
689 (description "TGL is the telegram library for telegram-cli.")
690 (home-page "https://github.com/vysheng/tgl")
691 (license license:lgpl2.1+))))
693 (define-public telegram-cli
694 (let ((commit "6547c0b21b977b327b3c5e8142963f4bc246187a")
697 (name "telegram-cli")
699 (git-version "1.3.1" revision commit))
705 (url "https://github.com/vysheng/tg.git")
708 (git-file-name name version))
710 (base32 "0c1w7jgska71jjbvg1y09v52549pwa4zkdjly18yxywn7gayd2p6"))))
711 (build-system gnu-build-system)
713 `(#:tests? #f ; No target
715 ((guix build copy-build-system)
716 ,@%gnu-build-system-modules)
718 (((guix build copy-build-system)
720 (guix build gnu-build-system)
724 ;; Use gcrypt instead of openssl.
727 (modify-phases %standard-phases
728 (add-after 'unpack 'trigger-bootstrap
730 (delete-file "configure")
732 (add-after 'trigger-bootstrap 'patch-tgl-and-tlparser
733 (lambda* (#:key inputs #:allow-other-keys)
734 (for-each delete-file
737 "Makefile.tl-parser"))
738 (substitute* "Makefile.in"
739 (("include \\$\\{srcdir\\}/Makefile\\.tl-parser")
741 (("include \\$\\{srcdir\\}/Makefile\\.tgl")
743 (("-I\\$\\{srcdir\\}/tgl")
744 (string-append "-I" (assoc-ref inputs "tgl")
747 (string-append "AUTO=" (assoc-ref inputs "tgl")
748 "/include/tgl/auto"))
750 (string-append "LIB=" (assoc-ref inputs "tgl")
755 (apply (assoc-ref copy:%standard-phases 'install)
758 ("." "etc/telegram-cli"
759 #:include-regexp ("\\.pub$")
760 #:exclude ("tg-server.pub")))
763 `(("autoconf" ,autoconf)
764 ("automake" ,automake)
766 ("pkg-config" ,pkg-config)))
768 `(("jansson" ,jansson)
769 ("libconfig" ,libconfig)
770 ("libevent" ,libevent)
771 ("libgcrypt" ,libgcrypt)
776 ("readline" ,readline)
778 ("tl-parser" ,tl-parser)
780 (synopsis "Telegram Messenger CLI")
781 (description "TG is the command-line interface for Telegram Messenger.")
782 (home-page "https://github.com/vysheng/tg")
783 (license license:gpl2+))))