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 `(("gcc" ,gcc-9) ; keep in line with telegram-desktop
131 ("pkg-config" ,pkg-config)
132 ("python" ,python-wrapper)
137 ("libjpeg" ,libjpeg-turbo)
143 (url "https://chromium.googlesource.com/webm/libvpx")
144 (commit "5b63f0f821e94f8072eb483014cfc33b05978bb9")))
146 (git-file-name "libvpx-for-webrtc-for-telegram-desktop" version))
148 (base32 "1psvxaddihlw1k5n0anxif3qli6zyw2sa2ywn6mkb8six9myrp68"))))
154 (url "https://chromium.googlesource.com/libyuv/libyuv")
155 (commit "ad890067f661dc747a975bc55ba3767fe30d4452")))
157 (git-file-name "libyuv-for-webrtc-for-telegram-desktop" version))
159 (base32 "01knnk4h247rq536097n9n3s3brxlbby3nv3ppdgsqfda3k159ll"))))
162 ("protobuf" ,protobuf)
163 ("pulseaudio" ,pulseaudio)
167 (synopsis "WebRTC support for Telegram Desktop")
168 (description "WebRTC-for-Telegram-Desktop is a custom WebRTC fork by
169 Telegram project, for its use in telegram desktop client.")
170 (home-page "https://github.com/desktop-app/tg_owt")
176 (license:non-copyleft "file:///src/third_party/libyuv/LICENSE")
180 (license:non-copyleft "file:///src/third_party/pffft/LICENSE")
183 ;; LibSRTP, LibVPx, UsrSCTP and Others
186 (define-public rlottie-for-telegram-desktop
187 (let ((commit "cbd43984ebdf783e94c8303c41385bf82aa36d5b")
193 (git-version "0.0.1" revision commit))
199 (url "https://github.com/desktop-app/rlottie.git")
202 (git-file-name "rlottie-for-telegram-desktop" version))
204 (base32 "1lxpbgbhps9rmck036mgmiknqrzpjxpas8n7qxykv6pwzn0c8n0c"))))
212 (modify-phases %standard-phases
213 (add-after 'unpack 'patch-cxx-flags
215 (substitute* "meson.build"
220 (define-public libtgvoip-for-telegram-desktop
221 (let ((commit "13a5fcb16b04472d808ce122abd695dbf5d206cd")
227 (git-version "2.4.4" revision commit))
233 (url "https://github.com/telegramdesktop/libtgvoip.git")
236 (git-file-name "libtgvoip-for-telegram-desktop" version))
238 (base32 "12p6s7vxkf1gh1spdckkdxrx7bjzw881ds9bky7l5fw751cwb3xd"))))
243 "--disable-dsp" ; FIXME
244 "--enable-audio-callback"
248 (modify-phases %standard-phases
249 (add-after 'unpack 'patch-linkers
251 (substitute* "Makefile.am"
252 (("\\$\\(CRYPTO_LIBS\\) \\$\\(OPUS_LIBS\\)")
253 "$(CRYPTO_LIBS) $(OPUS_LIBS) $(ALSA_LIBS) $(PULSE_LIBS)"))
254 (substitute* "tgvoip.pc.in"
256 "libcrypto opus alsa libpulse"))
259 `(("autoconf" ,autoconf)
260 ("automake" ,automake)
262 ("pkg-config" ,pkg-config)))))))
264 (define-public telegram-desktop
266 (name "telegram-desktop")
273 (url "https://github.com/telegramdesktop/tdesktop.git")
275 (string-append "v" version))))
277 (git-file-name name version))
279 (base32 "1lqs06scqvzg37a2py8jk7nnlvk42jjifcpnhdd5rgd5biw70nyx"))
280 (modules '((guix build utils)
286 '( ;; Not available in Guix.
287 "SPMediaKeyTap" "statusnotifieritem" "tgcalls")))
288 (with-directory-excursion "Telegram/ThirdParty"
289 (for-each delete-file-recursively
290 (lset-difference string=?
292 (cons* "." ".." keep))))
294 (build-system qt-build-system)
296 `(#:tests? #f ; No target
298 (,@%qt-build-system-modules
299 (guix build glib-or-gtk-build-system))
301 ((guix build qt-build-system)
302 ((guix build glib-or-gtk-build-system)
303 #:prefix glib-or-gtk:)
308 ;; Client applications must provide their own API-ID and API-HASH,
309 ;; see also <https://core.telegram.org/api/obtaining_api_id>.
310 ;; In case, that the credentials below fail to work, contact
311 ;; Raghav Gururajan <rg@raghavgururajan.name>
312 "-DTDESKTOP_API_ID=2791056"
313 "-DTDESKTOP_API_HASH=582d6d0b44f7a2de949e99271fd8b3f2"
314 ;; Use bundled fonts as fallback.
315 "-DDESKTOP_APP_USE_PACKAGED_FONTS=OFF")
317 (modify-phases %standard-phases
318 (add-after 'unpack 'make-writable
320 (for-each make-file-writable (find-files "."))
322 (add-after 'make-writable 'copy-inputs
323 (lambda* (#:key inputs outputs #:allow-other-keys)
327 (copy-recursively src dst)
328 (for-each make-file-writable (find-files dst))))
329 `(("cmake" ,(assoc-ref inputs "cmake-helpers"))
330 ("Telegram/codegen" ,(assoc-ref inputs "codegen-source"))
331 ("Telegram/lib_base" ,(assoc-ref inputs "lib-base-source"))
332 ("Telegram/lib_crl" ,(assoc-ref inputs "lib-crl-source"))
333 ("Telegram/lib_lottie"
334 ,(assoc-ref inputs "lib-lottie-source"))
335 ("Telegram/lib_qr" ,(assoc-ref inputs "lib-qr-source"))
336 ("Telegram/lib_rlottie"
337 ,(assoc-ref inputs "lib-rlottie-source"))
338 ("Telegram/lib_rpl" ,(assoc-ref inputs "lib-rpl-source"))
339 ("Telegram/lib_spellcheck"
340 ,(assoc-ref inputs "lib-spellcheck-source"))
341 ("Telegram/lib_storage"
342 ,(assoc-ref inputs "lib-storage-source"))
343 ("Telegram/lib_tl" ,(assoc-ref inputs "lib-tl-source"))
344 ("Telegram/lib_ui" ,(assoc-ref inputs "lib-ui-source"))
345 ("Telegram/lib_webrtc" ,(assoc-ref inputs "lib-webrtc-source"))
346 ("Telegram/ThirdParty/tgcalls"
347 ,(assoc-ref inputs "tgcalls-source"))))
349 (add-before 'configure 'patch-cxx-flags
351 (substitute* "cmake/options_linux.cmake"
352 (("class-memaccess") "all"))
354 (add-after 'install 'glib-or-gtk-compile-schemas
355 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
356 (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
357 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
364 (url "https://github.com/desktop-app/cmake_helpers.git")
365 (commit "695fabda6830b58bdc02d09db70531d5dececcd0")))
367 (git-file-name "cmake-helpers-for-telegram-desktop" version))
369 (base32 "1j3ppgfmihcjl22w5jk8jhwif10i9wbycq5zqnssn6pnhnj7di5i"))))
370 ("cmake-shared" ,cmake-shared)
371 ("extra-cmake-modules" ,extra-cmake-modules)
373 ("glib:bin" ,glib "bin")
374 ("gobject-introspection" ,gobject-introspection)
375 ("gtk+:bin" ,gtk+ "bin")
376 ("pkg-config" ,pkg-config)
377 ("python" ,python-wrapper)
378 ("qttools" ,qttools)))
382 ("catch" ,catch-framework2)
388 (url "https://github.com/desktop-app/codegen.git")
389 (commit "127968de8129e8ccfa6ac50721c70415a5a087c3")))
391 (git-file-name "codegen" version))
393 (base32 "036hzjrsk134ky62192nra43rsln5kh5gz20q1920s922661zky2"))))
394 ("expected" ,libexpected)
395 ("fcitx-qt5" ,fcitx-qt5)
396 ("fcitx5-qt" ,fcitx5-qt)
401 ("hunspell" ,hunspell)
403 ("kwayland" ,kwayland)
409 (url "https://github.com/desktop-app/lib_base.git")
410 (commit "f1e4168081428fa451d2f50eee7b1c448268c43a")))
412 (git-file-name "lib-base-for-telegram-desktop" version))
414 (base32 "0piqp7llwi7sfy4c15g0p8ihr90rz1qps6q5fkl1iasrf5ysw8qc"))))
420 (url "https://github.com/desktop-app/lib_crl.git")
421 (commit "16150bf71d79382738114b913f137ec1a1a7630c")))
423 (git-file-name "lib-crl-for-telegram-desktop" version))
425 (base32 "0qhagdr26aqb9w7wnchcmk1j7ln28x3wbkkkm06b8h0mybksbj7q"))))
431 (url "https://github.com/desktop-app/lib_lottie.git")
432 (commit "fb40f379d82ffa1fc7506e9a8dddcf48847715ae")))
434 (git-file-name "lib-lottie-for-telegram-desktop" version))
436 (base32 "1vq0mqxcrrv7akcqk9cl4mm61zw6dcfmy8adl0pcp49kynm64saw"))))
442 (url "https://github.com/desktop-app/lib_qr.git")
443 (commit "92ce41a690a463eb462089a4eb1e51e019308018")))
445 (git-file-name "lib-qr-for-telegram-desktop" version))
447 (base32 "182939nv7xs9b3bgah3gl5y9hx5r59mabd2jw3z6717vc96qi2pj"))))
448 ("lib-rlottie-source"
453 (url "https://github.com/desktop-app/lib_rlottie.git")
454 (commit "0671bf70547381effcf442ec9618e04502a8adbc")))
456 (git-file-name "lib-rlottie-for-telegram-desktop" version))
458 (base32 "05qnza7j15356s8jq16pkbyp4zr586lssmd86lz5jq23lcb3raxv"))))
464 (url "https://github.com/desktop-app/lib_rpl.git")
465 (commit "e1b96399d9031c4ef0354631e6bb375029d29d9f")))
467 (git-file-name "lib-rpl-for-telegram-desktop" version))
469 (base32 "1wvqazljd2kq1fxlj250jhjrig529499bym9p81dx33kh1l9dgss"))))
470 ("lib-spellcheck-source"
475 (url "https://github.com/desktop-app/lib_spellcheck.git")
476 (commit "1b540b38ed78e9a3cba93e9ba4ce4525ab692277")))
478 (git-file-name "lib-spellcheck-for-telegram-desktop" version))
480 (base32 "0a7042h5zrdvgs7v153ral2dh1zj84di5yjcmgcry5k4s1im9di7"))))
481 ("lib-storage-source"
486 (url "https://github.com/desktop-app/lib_storage.git")
487 (commit "cbe51722b73cfa9ff27bd59294b08aa5ee33c936")))
489 (git-file-name "lib-storage-for-telegram-desktop" version))
491 (base32 "045l5xsyagyz17gbhmmvl2miss4nb92p0dmza7yfs9pkg9gs0f87"))))
497 (url "https://github.com/desktop-app/lib_tl.git")
498 (commit "404c83d77e5edb8a39f8e9f56a6340960fe5070e")))
500 (git-file-name "lib-tl-for-telegram-desktop" version))
502 (base32 "1k34nkvvcjqw5q81n1qmklid60cvzjk4lmn9qjimk437m6wbii7f"))))
508 (url "https://github.com/desktop-app/lib_ui.git")
509 (commit "e14bc4681d69c1b538b8c5af51501077ae5a8a86")))
511 (git-file-name "lib-ui-for-telegram-desktop" version))
513 (base32 "04b1x4bswk3bxqrwpv5g7w4frkprrwf0px6aibh6z4drinv08wsv"))))
519 (url "https://github.com/desktop-app/lib_webrtc.git")
520 (commit "60d5c43daf882a6c03944a3e6198b5f35b654a0e")))
522 (git-file-name "lib-webrtc-for-telegram-desktop" version))
524 (base32 "0mxmbw8i37axllg9h976p6np2gcfyci6xwwl9hc9mhs49vwwsw5s"))))
525 ("libdbusmenu-qt" ,libdbusmenu-qt)
526 ("libjpeg" ,libjpeg-turbo)
527 ("libtgvoip" ,libtgvoip-for-telegram-desktop)
529 ("materialdecoration" ,materialdecoration)
535 ("pulseaudio" ,pulseaudio)
536 ("qrcodegen" ,qrcodegen-cpp)
539 ("qtimageformats" ,qtimageformats)
540 ("qtwayland" ,qtwayland)
541 ("range-v3" ,range-v3)
542 ("rlottie" ,rlottie-for-telegram-desktop)
548 (url "https://github.com/TelegramMessenger/tgcalls.git")
549 (commit "71addf5b41cb6bb6844f75e977edae0020938930")))
551 (git-file-name "tgcalls-for-telegram-desktop" version))
553 (base32 "1zrjxf03n3ad8b95gwjarmq4gj5i5cwhlg93qcjv2232kksh29iy"))))
554 ("webrtc" ,webrtc-for-telegram-desktop)
557 ("xcb-keysyms" ,xcb-util-keysyms)
562 (synopsis "Telegram Desktop")
563 (description "Telegram desktop is the official desktop version of the
564 Telegram instant messenger.")
565 (home-page "https://desktop.telegram.org/")
573 (define-public tl-parser
574 (let ((commit "1933e76f8f4fb74311be723b432e4c56e3a5ec06")
579 (git-version "0" revision commit))
585 (url "https://github.com/vysheng/tl-parser.git")
588 (git-file-name name version))
590 (base32 "13cwi247kajzpkbl86hnwmn1sn2h6rqndz6khajbqj0mlw9mv4hq"))))
591 (build-system cmake-build-system)
593 `(#:tests? #f ; No target
595 ((guix build copy-build-system)
596 ,@%cmake-build-system-modules)
598 (((guix build copy-build-system)
600 (guix build cmake-build-system)
603 (modify-phases %standard-phases
606 (apply (assoc-ref copy:%standard-phases 'install)
609 #:include ("tl-parser"))
610 ("../source" "include/tl-parser"
611 #:include-regexp ("\\.h$")))
613 (synopsis "Parse tl scheme to tlo")
614 (description "TL-Parser is a tl scheme to tlo file parser. It was
615 formerly a part of telegram-cli, but now being maintained separately.")
616 (home-page "https://github.com/vysheng/tl-parser")
617 (license license:gpl2+))))
620 (let ((commit "ffb04caca71de0cddf28cd33a4575922900a59ed")
625 (git-version "2.0.1" revision commit))
631 (url "https://github.com/vysheng/tgl.git")
634 (git-file-name name version))
636 (base32 "0cf5s7ygslb5klg1qv9qdc3hivhspmvh3zkacyyhd2yyikb5p0f9"))))
637 (build-system gnu-build-system)
639 `(#:tests? #f ; No target
641 ((guix build copy-build-system)
642 ,@%gnu-build-system-modules)
644 (((guix build copy-build-system)
646 (guix build gnu-build-system)
650 ;; Use gcrypt instead of openssl.
652 ;; Enable extended queries system.
654 ;; Include libevent-based net and timers.
657 (modify-phases %standard-phases
658 (add-after 'unpack 'trigger-bootstrap
660 (delete-file "configure")
662 (add-after 'trigger-bootstrap 'patch-tl-parser
664 (delete-file "Makefile.tl-parser")
665 (substitute* "Makefile.in"
666 (("include \\$\\{srcdir\\}/Makefile\\.tl-parser")
668 (("\\$\\{EXE\\}/tl-parser")
673 (apply (assoc-ref copy:%standard-phases 'install)
677 #:include-regexp ("\\.h$"))
681 `(("autoconf" ,autoconf)
682 ("automake" ,automake)
684 ("pkg-config" ,pkg-config)))
686 `(("libevent" ,libevent)
687 ("libgcrypt" ,libgcrypt)
688 ("tl-parser" ,tl-parser)
690 (synopsis "Telegram Library")
691 (description "TGL is the telegram library for telegram-cli.")
692 (home-page "https://github.com/vysheng/tgl")
693 (license license:lgpl2.1+))))
695 (define-public telegram-cli
696 (let ((commit "6547c0b21b977b327b3c5e8142963f4bc246187a")
699 (name "telegram-cli")
701 (git-version "1.3.1" revision commit))
707 (url "https://github.com/vysheng/tg.git")
710 (git-file-name name version))
712 (base32 "0c1w7jgska71jjbvg1y09v52549pwa4zkdjly18yxywn7gayd2p6"))))
713 (build-system gnu-build-system)
715 `(#:tests? #f ; No target
717 ((guix build copy-build-system)
718 ,@%gnu-build-system-modules)
720 (((guix build copy-build-system)
722 (guix build gnu-build-system)
726 ;; Use gcrypt instead of openssl.
729 (modify-phases %standard-phases
730 (add-after 'unpack 'trigger-bootstrap
732 (delete-file "configure")
734 (add-after 'trigger-bootstrap 'patch-tgl-and-tlparser
735 (lambda* (#:key inputs #:allow-other-keys)
736 (for-each delete-file
739 "Makefile.tl-parser"))
740 (substitute* "Makefile.in"
741 (("include \\$\\{srcdir\\}/Makefile\\.tl-parser")
743 (("include \\$\\{srcdir\\}/Makefile\\.tgl")
745 (("-I\\$\\{srcdir\\}/tgl")
746 (string-append "-I" (assoc-ref inputs "tgl")
749 (string-append "AUTO=" (assoc-ref inputs "tgl")
750 "/include/tgl/auto"))
752 (string-append "LIB=" (assoc-ref inputs "tgl")
757 (apply (assoc-ref copy:%standard-phases 'install)
760 ("." "etc/telegram-cli"
761 #:include-regexp ("\\.pub$")
762 #:exclude ("tg-server.pub")))
765 `(("autoconf" ,autoconf)
766 ("automake" ,automake)
768 ("pkg-config" ,pkg-config)))
770 `(("jansson" ,jansson)
771 ("libconfig" ,libconfig)
772 ("libevent" ,libevent)
773 ("libgcrypt" ,libgcrypt)
778 ("readline" ,readline)
780 ("tl-parser" ,tl-parser)
782 (synopsis "Telegram Messenger CLI")
783 (description "TG is the command-line interface for Telegram Messenger.")
784 (home-page "https://github.com/vysheng/tg")
785 (license license:gpl2+))))