Merge branch 'staging'
[jackhill/guix/guix.git] / gnu / packages / telegram.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
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.
10 ;;;
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.
15 ;;;
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/>.
18
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 gtk)
38 #:use-module (gnu packages image)
39 #:use-module (gnu packages kde-frameworks)
40 #:use-module (gnu packages language)
41 #:use-module (gnu packages libreoffice)
42 #:use-module (gnu packages linux)
43 #:use-module (gnu packages lxqt)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages protobuf)
46 #:use-module (gnu packages pulseaudio)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages qt)
49 #:use-module (gnu packages telephony)
50 #:use-module (gnu packages tls)
51 #:use-module (gnu packages video)
52 #:use-module (gnu packages xiph)
53 #:use-module (gnu packages xorg)
54 #:use-module ((guix licenses) #:prefix license:)
55 #:use-module (guix packages)
56 #:use-module (guix git-download)
57 #:use-module (guix build-system cmake)
58 #:use-module (guix build-system glib-or-gtk)
59 #:use-module (guix build-system gnu)
60 #:use-module (guix build-system meson)
61 #:use-module (guix build-system qt))
62
63 (define-public webrtc-for-telegram-desktop
64 (let ((commit "fa86fcc00c218813d61a272a56feab55c76a1ab9")
65 (revision "52"))
66 (hidden-package
67 (package
68 (name "webrtc-for-telegram-desktop")
69 (version
70 (git-version "0" revision commit))
71 (source
72 (origin
73 (method git-fetch)
74 (uri
75 (git-reference
76 (url "https://github.com/desktop-app/tg_owt.git")
77 (commit commit)))
78 (file-name
79 (git-file-name name version))
80 (sha256
81 (base32 "06gcrlym6vqqw7zlds9lpwyg37d5m81d87h16aps19v0v9gzan0l"))
82 (modules '((guix build utils)
83 (ice-9 ftw)
84 (srfi srfi-1)))
85 (snippet
86 `(begin
87 (let ((keep
88 '( ;; Custom forks which are incompatible with the ones in Guix.
89 "abseil-cpp" "libsrtp" "openh264" "rnnoise"
90 ;; Not available in Guix.
91 "pffft" "usrsctp"
92 ;; Has cmake support files for libvpx input.
93 "libvpx")))
94 (with-directory-excursion "src/third_party"
95 (for-each delete-file-recursively
96 (lset-difference string=?
97 (scandir ".")
98 (cons* "." ".." keep))))
99 #t)))))
100 (build-system cmake-build-system)
101 (arguments
102 `(#:tests? #f ; No target
103 #:configure-flags
104 (list
105 "-DCMAKE_C_FLAGS=-fPIC"
106 "-DCMAKE_CXX_FLAGS=-fPIC")
107 #:phases
108 (modify-phases %standard-phases
109 (add-after 'unpack 'copy-inputs
110 (lambda* (#:key inputs outputs #:allow-other-keys)
111 (let* ((libvpx-from (assoc-ref inputs "libvpx"))
112 (libyuv-from (assoc-ref inputs "libyuv"))
113 (libvpx-to (string-append (getcwd)
114 "/src/third_party/libvpx/source/libvpx"))
115 (libyuv-to (string-append (getcwd)
116 "/src/third_party/libyuv")))
117 (copy-recursively libvpx-from libvpx-to)
118 (copy-recursively libyuv-from libyuv-to))
119 #t)))))
120 (native-inputs
121 `(("pkg-config" ,pkg-config)
122 ("python" ,python-wrapper)
123 ("yasm" ,yasm)))
124 (inputs
125 `(("alsa" ,alsa-lib)
126 ("ffmpeg" ,ffmpeg)
127 ("libjpeg" ,libjpeg-turbo)
128 ("libvpx"
129 ,(origin
130 (method git-fetch)
131 (uri
132 (git-reference
133 (url "https://chromium.googlesource.com/webm/libvpx")
134 (commit "5b63f0f821e94f8072eb483014cfc33b05978bb9")))
135 (file-name
136 (git-file-name "libvpx-for-webrtc-for-telegram-desktop" version))
137 (sha256
138 (base32 "1psvxaddihlw1k5n0anxif3qli6zyw2sa2ywn6mkb8six9myrp68"))))
139 ("libyuv"
140 ,(origin
141 (method git-fetch)
142 (uri
143 (git-reference
144 (url "https://chromium.googlesource.com/libyuv/libyuv")
145 (commit "ad890067f661dc747a975bc55ba3767fe30d4452")))
146 (file-name
147 (git-file-name "libyuv-for-webrtc-for-telegram-desktop" version))
148 (sha256
149 (base32 "01knnk4h247rq536097n9n3s3brxlbby3nv3ppdgsqfda3k159ll"))))
150 ("openssl" ,openssl)
151 ("opus" ,opus)
152 ("protobuf" ,protobuf)
153 ("pulseaudio" ,pulseaudio)))
154 (synopsis "WebRTC support for Telegram Desktop")
155 (description "WebRTC-for-Telegram-Desktop is a custom WebRTC fork by
156 Telegram project, for its use in telegram desktop client.")
157 (home-page "https://github.com/desktop-app/tg_owt")
158 (license
159 (list
160 ;; Abseil-CPP
161 license:asl2.0
162 ;; LibYuv
163 (license:non-copyleft "file:///src/third_party/libyuv/LICENSE")
164 ;; OpenH264
165 license:bsd-2
166 ;; PFFFT
167 (license:non-copyleft "file:///src/third_party/pffft/LICENSE")
168 ;; RnNoise
169 license:gpl3
170 ;; LibSRTP, LibVPx, UsrSCTP and Others
171 license:bsd-3))))))
172
173 (define-public rlottie-for-telegram-desktop
174 (let ((commit "cbd43984ebdf783e94c8303c41385bf82aa36d5b")
175 (revision "671"))
176 (hidden-package
177 (package
178 (inherit rlottie)
179 (version
180 (git-version "0.0.1" revision commit))
181 (source
182 (origin
183 (method git-fetch)
184 (uri
185 (git-reference
186 (url "https://github.com/desktop-app/rlottie.git")
187 (commit commit)))
188 (file-name
189 (git-file-name "rlottie-for-telegram-desktop" version))
190 (sha256
191 (base32 "1lxpbgbhps9rmck036mgmiknqrzpjxpas8n7qxykv6pwzn0c8n0c"))))
192 (arguments
193 `(#:configure-flags
194 (list
195 "-Dlog=true"
196 "-Ddumptree=true"
197 "-Dtest=true")
198 #:phases
199 (modify-phases %standard-phases
200 (add-after 'unpack 'patch-cxx-flags
201 (lambda _
202 (substitute* "meson.build"
203 (("werror=true")
204 "werror=false"))
205 #t)))))))))
206
207 (define-public libtgvoip-for-telegram-desktop
208 (let ((commit "37d98e984fd6fa389262307db826d52ab86c8241")
209 (revision "87"))
210 (hidden-package
211 (package
212 (inherit libtgvoip)
213 (version
214 (git-version "2.4.4" revision commit))
215 (source
216 (origin
217 (method git-fetch)
218 (uri
219 (git-reference
220 (url "https://github.com/telegramdesktop/libtgvoip.git")
221 (commit commit)))
222 (file-name
223 (git-file-name "libtgvoip-for-telegram-desktop" version))
224 (sha256
225 (base32 "13dzvyq8p20nlhjihv18aj6y97czk07qdl0k6v81vp6mbwcldg7h"))))
226 (arguments
227 `(#:configure-flags
228 (list
229 "--disable-static"
230 "--disable-dsp" ; FIXME
231 "--enable-audio-callback"
232 "--with-alsa"
233 "--with-pulse")
234 #:phases
235 (modify-phases %standard-phases
236 (add-after 'unpack 'patch-linkers
237 (lambda _
238 (substitute* "Makefile.am"
239 (("\\$\\(CRYPTO_LIBS\\) \\$\\(OPUS_LIBS\\)")
240 "$(CRYPTO_LIBS) $(OPUS_LIBS) $(ALSA_LIBS) $(PULSE_LIBS)"))
241 (substitute* "tgvoip.pc.in"
242 (("libcrypto opus")
243 "libcrypto opus alsa libpulse"))
244 #t)))))
245 (native-inputs
246 `(("autoconf" ,autoconf)
247 ("automake" ,automake)
248 ("libtool" ,libtool)
249 ("pkg-config" ,pkg-config)))))))
250
251 (define-public telegram-desktop
252 (package
253 (name "telegram-desktop")
254 (version "2.5.1")
255 (source
256 (origin
257 (method git-fetch)
258 (uri
259 (git-reference
260 (url "https://github.com/telegramdesktop/tdesktop.git")
261 (commit
262 (string-append "v" version))))
263 (file-name
264 (git-file-name name version))
265 (sha256
266 (base32 "0drirhkr9gnm1g03lcqmvap5ljlk859c29gbsm63hhsgv15dlw0y"))
267 (modules '((guix build utils)
268 (ice-9 ftw)
269 (srfi srfi-1)))
270 (snippet
271 `(begin
272 (let ((keep
273 '( ;; Not available in Guix.
274 "SPMediaKeyTap" "statusnotifieritem" "tgcalls")))
275 (with-directory-excursion "Telegram/ThirdParty"
276 (for-each delete-file-recursively
277 (lset-difference string=?
278 (scandir ".")
279 (cons* "." ".." keep))))
280 #t)))))
281 (build-system qt-build-system)
282 (arguments
283 `(#:tests? #f ; No target
284 #:imported-modules
285 (,@%qt-build-system-modules
286 (guix build glib-or-gtk-build-system))
287 #:modules
288 ((guix build qt-build-system)
289 ((guix build glib-or-gtk-build-system)
290 #:prefix glib-or-gtk:)
291 (guix build utils)
292 (ice-9 match))
293 #:configure-flags
294 (list
295 ;; Client applications must provide their own API-ID and API-HASH,
296 ;; see also <https://core.telegram.org/api/obtaining_api_id>.
297 ;; In case, that the credentials below fail to work, contact
298 ;; Raghav Gururajan <rg@raghavgururajan.name>
299 "-DTDESKTOP_API_ID=2791056"
300 "-DTDESKTOP_API_HASH=582d6d0b44f7a2de949e99271fd8b3f2"
301 ;; Use bundled fonts as fallback.
302 "-DDESKTOP_APP_USE_PACKAGED_FONTS=OFF")
303 #:phases
304 (modify-phases %standard-phases
305 (add-after 'unpack 'make-writable
306 (lambda _
307 (for-each make-file-writable (find-files "."))
308 #t))
309 (add-after 'make-writable 'copy-inputs
310 (lambda* (#:key inputs outputs #:allow-other-keys)
311 (for-each
312 (match-lambda
313 ((dst src)
314 (copy-recursively src dst)
315 (for-each make-file-writable (find-files dst))))
316 `(("cmake" ,(assoc-ref inputs "cmake-helpers"))
317 ("Telegram/codegen" ,(assoc-ref inputs "codegen-source"))
318 ("Telegram/lib_base" ,(assoc-ref inputs "lib-base-source"))
319 ("Telegram/lib_crl" ,(assoc-ref inputs "lib-crl-source"))
320 ("Telegram/lib_lottie"
321 ,(assoc-ref inputs "lib-lottie-source"))
322 ("Telegram/lib_qr" ,(assoc-ref inputs "lib-qr-source"))
323 ("Telegram/lib_rlottie"
324 ,(assoc-ref inputs "lib-rlottie-source"))
325 ("Telegram/lib_rpl" ,(assoc-ref inputs "lib-rpl-source"))
326 ("Telegram/lib_spellcheck"
327 ,(assoc-ref inputs "lib-spellcheck-source"))
328 ("Telegram/lib_storage"
329 ,(assoc-ref inputs "lib-storage-source"))
330 ("Telegram/lib_tl" ,(assoc-ref inputs "lib-tl-source"))
331 ("Telegram/lib_ui" ,(assoc-ref inputs "lib-ui-source"))
332 ("Telegram/lib_webrtc" ,(assoc-ref inputs "lib-webrtc-source"))
333 ("Telegram/ThirdParty/tgcalls"
334 ,(assoc-ref inputs "tgcalls-source"))))
335 #t))
336 (add-before 'configure 'patch-cxx-flags
337 (lambda _
338 (substitute* "cmake/options_linux.cmake"
339 (("class-memaccess") "all"))
340 #t))
341 (add-after 'install 'glib-or-gtk-compile-schemas
342 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
343 (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
344 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
345 (native-inputs
346 `(("cmake-helpers"
347 ,(origin
348 (method git-fetch)
349 (uri
350 (git-reference
351 (url "https://github.com/desktop-app/cmake_helpers.git")
352 (commit "a81345a28d407fb5acd5267ec6afa1864f4e8d5b")))
353 (file-name
354 (git-file-name "cmake-helpers-for-telegram-desktop" version))
355 (sha256
356 (base32 "0s5hxip68dmkaspjq6j30wx1r5v4prnrjza79hdbznz6i57a2248"))))
357 ("cmake-shared" ,cmake-shared)
358 ("extra-cmake-modules" ,extra-cmake-modules)
359 ("gcc" ,gcc-9)
360 ("glib:bin" ,glib "bin")
361 ("gobject-introspection" ,gobject-introspection)
362 ("gtk+:bin" ,gtk+ "bin")
363 ("pkg-config" ,pkg-config)
364 ("python" ,python-wrapper)
365 ("qttools" ,qttools)))
366 (inputs
367 `(("alsa" ,alsa-lib)
368 ("c++-gsl" ,c++-gsl)
369 ("catch" ,catch-framework2)
370 ("codegen-source"
371 ,(origin
372 (method git-fetch)
373 (uri
374 (git-reference
375 (url "https://github.com/desktop-app/codegen.git")
376 (commit "127968de8129e8ccfa6ac50721c70415a5a087c3")))
377 (file-name
378 (git-file-name "codegen" version))
379 (sha256
380 (base32 "036hzjrsk134ky62192nra43rsln5kh5gz20q1920s922661zky2"))))
381 ("expected" ,libexpected)
382 ("fcitx-qt5" ,fcitx-qt5)
383 ("fcitx5-qt" ,fcitx5-qt)
384 ("ffmpeg" ,ffmpeg)
385 ("glib" ,glib)
386 ("gtk+" ,gtk+)
387 ("hime" ,hime)
388 ("hunspell" ,hunspell)
389 ("iconv" ,libiconv)
390 ("lib-base-source"
391 ,(origin
392 (method git-fetch)
393 (uri
394 (git-reference
395 (url "https://github.com/desktop-app/lib_base.git")
396 (commit "81df0d0b7842be2b6c88f93dfa136b8efea4c9ad")))
397 (file-name
398 (git-file-name "lib-base-for-telegram-desktop" version))
399 (sha256
400 (base32 "0ikddprjnjvg0ic8jr2886xq0f18syp587q6z2kci9xmdnvjl217"))))
401 ("lib-crl-source"
402 ,(origin
403 (method git-fetch)
404 (uri
405 (git-reference
406 (url "https://github.com/desktop-app/lib_crl.git")
407 (commit "16150bf71d79382738114b913f137ec1a1a7630c")))
408 (file-name
409 (git-file-name "lib-crl-for-telegram-desktop" version))
410 (sha256
411 (base32 "0qhagdr26aqb9w7wnchcmk1j7ln28x3wbkkkm06b8h0mybksbj7q"))))
412 ("lib-lottie-source"
413 ,(origin
414 (method git-fetch)
415 (uri
416 (git-reference
417 (url "https://github.com/desktop-app/lib_lottie.git")
418 (commit "fb40f379d82ffa1fc7506e9a8dddcf48847715ae")))
419 (file-name
420 (git-file-name "lib-lottie-for-telegram-desktop" version))
421 (sha256
422 (base32 "1vq0mqxcrrv7akcqk9cl4mm61zw6dcfmy8adl0pcp49kynm64saw"))))
423 ("lib-qr-source"
424 ,(origin
425 (method git-fetch)
426 (uri
427 (git-reference
428 (url "https://github.com/desktop-app/lib_qr.git")
429 (commit "92ce41a690a463eb462089a4eb1e51e019308018")))
430 (file-name
431 (git-file-name "lib-qr-for-telegram-desktop" version))
432 (sha256
433 (base32 "182939nv7xs9b3bgah3gl5y9hx5r59mabd2jw3z6717vc96qi2pj"))))
434 ("lib-rlottie-source"
435 ,(origin
436 (method git-fetch)
437 (uri
438 (git-reference
439 (url "https://github.com/desktop-app/lib_rlottie.git")
440 (commit "0671bf70547381effcf442ec9618e04502a8adbc")))
441 (file-name
442 (git-file-name "lib-rlottie-for-telegram-desktop" version))
443 (sha256
444 (base32 "05qnza7j15356s8jq16pkbyp4zr586lssmd86lz5jq23lcb3raxv"))))
445 ("lib-rpl-source"
446 ,(origin
447 (method git-fetch)
448 (uri
449 (git-reference
450 (url "https://github.com/desktop-app/lib_rpl.git")
451 (commit "e1b96399d9031c4ef0354631e6bb375029d29d9f")))
452 (file-name
453 (git-file-name "lib-rpl-for-telegram-desktop" version))
454 (sha256
455 (base32 "1wvqazljd2kq1fxlj250jhjrig529499bym9p81dx33kh1l9dgss"))))
456 ("lib-spellcheck-source"
457 ,(origin
458 (method git-fetch)
459 (uri
460 (git-reference
461 (url "https://github.com/desktop-app/lib_spellcheck.git")
462 (commit "1b540b38ed78e9a3cba93e9ba4ce4525ab692277")))
463 (file-name
464 (git-file-name "lib-spellcheck-for-telegram-desktop" version))
465 (sha256
466 (base32 "0a7042h5zrdvgs7v153ral2dh1zj84di5yjcmgcry5k4s1im9di7"))))
467 ("lib-storage-source"
468 ,(origin
469 (method git-fetch)
470 (uri
471 (git-reference
472 (url "https://github.com/desktop-app/lib_storage.git")
473 (commit "cbe51722b73cfa9ff27bd59294b08aa5ee33c936")))
474 (file-name
475 (git-file-name "lib-storage-for-telegram-desktop" version))
476 (sha256
477 (base32 "045l5xsyagyz17gbhmmvl2miss4nb92p0dmza7yfs9pkg9gs0f87"))))
478 ("lib-tl-source"
479 ,(origin
480 (method git-fetch)
481 (uri
482 (git-reference
483 (url "https://github.com/desktop-app/lib_tl.git")
484 (commit "404c83d77e5edb8a39f8e9f56a6340960fe5070e")))
485 (file-name
486 (git-file-name "lib-tl-for-telegram-desktop" version))
487 (sha256
488 (base32 "1k34nkvvcjqw5q81n1qmklid60cvzjk4lmn9qjimk437m6wbii7f"))))
489 ("lib-ui-source"
490 ,(origin
491 (method git-fetch)
492 (uri
493 (git-reference
494 (url "https://github.com/desktop-app/lib_ui.git")
495 (commit "1e2799245cf2720a329ecb5cf5644fded669cce6")))
496 (file-name
497 (git-file-name "lib-ui-for-telegram-desktop" version))
498 (sha256
499 (base32 "0kd4njcvic2700f00qn25vn3b80vsd2flsm3pi2synnldkiy8lcw"))))
500 ("lib-webrtc-source"
501 ,(origin
502 (method git-fetch)
503 (uri
504 (git-reference
505 (url "https://github.com/desktop-app/lib_webrtc.git")
506 (commit "4bc51d6f6d5740159fdb51cb1593e80ce149ed4e")))
507 (file-name
508 (git-file-name "lib-webrtc-for-telegram-desktop" version))
509 (sha256
510 (base32 "06hpyq4qglrj3cb1xg8ghlmzm9ra8f5n6vm7hcy67n2wk8sy4cal"))))
511 ("libdbusmenu-qt" ,libdbusmenu-qt)
512 ("libjpeg" ,libjpeg-turbo)
513 ("libtgvoip" ,libtgvoip-for-telegram-desktop)
514 ("lz4" ,lz4)
515 ("materialdecoration" ,materialdecoration)
516 ("minizip" ,minizip)
517 ("nimf" ,nimf)
518 ("openal" ,openal)
519 ("openssl" ,openssl)
520 ("opus" ,opus)
521 ("pulseaudio" ,pulseaudio)
522 ("qrcodegen" ,qrcodegen-cpp)
523 ("qt" ,qtbase)
524 ("qt5ct" ,qt5ct)
525 ("qtimageformats" ,qtimageformats)
526 ("qtwayland" ,qtwayland)
527 ("range-v3" ,range-v3)
528 ("rlottie" ,rlottie-for-telegram-desktop)
529 ("tgcalls-source"
530 ,(origin
531 (method git-fetch)
532 (uri
533 (git-reference
534 (url "https://github.com/TelegramMessenger/tgcalls.git")
535 (commit "178983f72312ca8bd422bc73810fd63f1a89bd9d")))
536 (file-name
537 (git-file-name "tgcalls-for-telegram-desktop" version))
538 (sha256
539 (base32 "1xad65c9m6mj6zdj08flafvh8xjkd7xi9r1agcyc64y69lr427d0"))))
540 ("webrtc" ,webrtc-for-telegram-desktop)
541 ("x11" ,libx11)
542 ("xcb" ,libxcb)
543 ("xcb-keysyms" ,xcb-util-keysyms)
544 ("xxhash" ,xxhash)
545 ("zlib" ,zlib)))
546 (propagated-inputs
547 `(("dconf" ,dconf)))
548 (synopsis "Telegram Desktop")
549 (description "Telegram desktop is the official desktop version of the
550 Telegram instant messager.")
551 (home-page "https://desktop.telegram.org/")
552 (license
553 (list
554 ;; ThirdParty
555 license:lgpl2.1+
556 ;; Others
557 license:gpl3+))))