Subject: [PATCH 6/6] gnu: Update telegram-desktop to 4.11.8

From: Saku Laesvuori <[email-masked]>
Date: Mon, 27 Nov 2023 21:26:10 +0200

* gnu/packages/telegram.scm: Import (gnu packages boost).
(libyuv-for-telegram-desktop, cmake-helpers-for-telegram-desktop,
codegen-for-telegram-desktop, lib-base-for-telegram-desktop,
lib-crl-for-telegram-desktop, lib-lottie-for-telegram-desktop,
lib-qr-for-telegram-desktop, lib-storage-for-telegram-desktop,
lib-tl-for-telegram-desktop, lib-webrtc-for-telegram-desktop,
tgcalls-for-telegram-desktop, webrtc-for-telegram-desktop): Bump to
submodule checkout.
(cmake-helpers-for-telegram-desktop)[patches]: Add patches to unbundle
gsl and cppgir.
(lib-base-for-telegram-desktop)[patches]: Add patch to fix build.
(libprisma-for-telegram-desktop, cppgir-for-telegram-desktop): New
variables.
(telegram-desktop): Update to 4.11.8.
[phases]<unpack-additional-sources>: Add libprisma-for-telegram-desktop.
<patch-gir-ignore-paths>: New phase.
[inputs]: Add boost, cppgir-for-telegram-desktop, expected-lite and
gobject-introspection.
* gnu/local.mk (dist_patch_DATA): Add new patches.
* gnu/packages/patches/telegram-desktop-fix-lib-base-build.patch: New file.
* gnu/packages/patches/telegram-desktop-unbundle-cppgir.patch: New file.
* gnu/packages/patches/telegram-desktop-unbundle-gsl.patch: New file.

Change-Id: I18bdd5a7e3f23464e01a05c5f7f8e595fbc15ebf
---
 gnu/local.mk                                  |  3 +
 .../telegram-desktop-fix-lib-base-build.patch | 24 +++++
 .../telegram-desktop-unbundle-cppgir.patch    | 45 +++++++++
 .../telegram-desktop-unbundle-gsl.patch       | 33 +++++++
 gnu/packages/telegram.scm                     | 99 +++++++++++++------
 5 files changed, 176 insertions(+), 28 deletions(-)
 create mode 100644 gnu/packages/patches/telegram-desktop-fix-lib-base-build.patch
 create mode 100644 gnu/packages/patches/telegram-desktop-unbundle-cppgir.patch
 create mode 100644 gnu/packages/patches/telegram-desktop-unbundle-gsl.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index ae332c6390..ec40871370 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2035,6 +2035,9 @@ dist_patch_DATA =						\
   %D%/packages/patches/texinfo-headings-single.patch		\
   %D%/packages/patches/texinfo-5-perl-compat.patch		\
   %D%/packages/patches/telegram-desktop-allow-disable-libtgvoip.patch   \
+  %D%/packages/patches/telegram-desktop-fix-lib-base-build.patch   \
+  %D%/packages/patches/telegram-desktop-unbundle-cppgir.patch   \
+  %D%/packages/patches/telegram-desktop-unbundle-gsl.patch   \
   %D%/packages/patches/telegram-purple-adjust-test.patch	\
   %D%/packages/patches/teuchos-remove-duplicate-using.patch	\
   %D%/packages/patches/texi2html-document-encoding.patch	\
diff --git a/gnu/packages/patches/telegram-desktop-fix-lib-base-build.patch b/gnu/packages/patches/telegram-desktop-fix-lib-base-build.patch
new file mode 100644
index 0000000000..6cc84d40f5
--- /dev/null
+++ b/gnu/packages/patches/telegram-desktop-fix-lib-base-build.patch
@@ -0,0 +1,24 @@
+From 8d1273f89b8d0241c86c56792fc0811b0d9d746f Mon Sep 17 00:00:00 2001
+From: Saku Laesvuori <[email-masked]>
+Date: Sun, 26 Nov 2023 23:13:38 +0200
+Subject: [PATCH] Fix build
+
+---
+ base/qt/qt_compare.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/base/qt/qt_compare.h b/base/qt/qt_compare.h
+index ca03fa2..948e5e9 100644
+--- a/base/qt/qt_compare.h
++++ b/base/qt/qt_compare.h
+@@ -8,6 +8,7 @@
+ 
+ #include <compare>
+ #include <gsl/pointers>
++#include <variant>
+ 
+ #include <QString>
+ 
+-- 
+2.41.0
+
diff --git a/gnu/packages/patches/telegram-desktop-unbundle-cppgir.patch b/gnu/packages/patches/telegram-desktop-unbundle-cppgir.patch
new file mode 100644
index 0000000000..70c96b320c
--- /dev/null
+++ b/gnu/packages/patches/telegram-desktop-unbundle-cppgir.patch
@@ -0,0 +1,45 @@
+From a3c3c1ae0ec15f3ca5ea7696d92958ecf68688a7 Mon Sep 17 00:00:00 2001
+From: Saku Laesvuori <[email-masked]>
+Date: Sun, 26 Nov 2023 12:22:27 +0200
+Subject: [PATCH] Unbundle cppgir
+
+---
+ external/glib/CMakeLists.txt        | 8 --------
+ external/glib/generate_cppgir.cmake | 2 ++
+ 2 files changed, 2 insertions(+), 8 deletions(-)
+
+diff --git a/external/glib/CMakeLists.txt b/external/glib/CMakeLists.txt
+index 3c6fe4b..ee057a4 100644
+--- a/external/glib/CMakeLists.txt
++++ b/external/glib/CMakeLists.txt
+@@ -7,14 +7,6 @@
+ add_library(external_glib INTERFACE IMPORTED GLOBAL)
+ add_library(desktop-app::external_glib ALIAS external_glib)
+ 
+-function(add_cppgir) # isolate scope
+-    set(BUILD_TESTING OFF)
+-    set(BUILD_DOC OFF)
+-    set(BUILD_EXAMPLES OFF)
+-    add_subdirectory(cppgir EXCLUDE_FROM_ALL)
+-endfunction()
+-add_cppgir()
+-
+ include(generate_cppgir.cmake)
+ generate_cppgir(external_glib Gio-2.0)
+ 
+diff --git a/external/glib/generate_cppgir.cmake b/external/glib/generate_cppgir.cmake
+index c9872a6..7925cf4 100644
+--- a/external/glib/generate_cppgir.cmake
++++ b/external/glib/generate_cppgir.cmake
+@@ -4,6 +4,8 @@
+ # For license and copyright information please follow this link:
+ # https://github.com/desktop-app/legal/blob/master/LEGAL
+ 
++find_package(CppGir REQUIRED gi)
++
+ function(generate_cppgir target_name gir)
+     # cppgir generates all the dependent headers everytime, better to have a global folder
+     set(gen_dst ${CMAKE_BINARY_DIR}/gen)
+-- 
+2.41.0
+
diff --git a/gnu/packages/patches/telegram-desktop-unbundle-gsl.patch b/gnu/packages/patches/telegram-desktop-unbundle-gsl.patch
new file mode 100644
index 0000000000..56338640f9
--- /dev/null
+++ b/gnu/packages/patches/telegram-desktop-unbundle-gsl.patch
@@ -0,0 +1,33 @@
+From 9271e1db51f3409d7ecc2afcb130fce5ca15fcbc Mon Sep 17 00:00:00 2001
+From: Saku Laesvuori <[email-masked]>
+Date: Sun, 26 Nov 2023 11:09:46 +0200
+Subject: [PATCH] Revert "Force usage of GSL fork because of a libstdc++ bug."
+
+This reverts commit 982546b169df3d479e6511425870327559b38a89.
+---
+ external/gsl/CMakeLists.txt | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/external/gsl/CMakeLists.txt b/external/gsl/CMakeLists.txt
+index 8eaf19c..344f948 100644
+--- a/external/gsl/CMakeLists.txt
++++ b/external/gsl/CMakeLists.txt
+@@ -7,7 +7,6 @@
+ add_library(external_gsl INTERFACE IMPORTED GLOBAL)
+ add_library(desktop-app::external_gsl ALIAS external_gsl)
+ 
+-#[[
+ if (DESKTOP_APP_USE_PACKAGED)
+     if (DESKTOP_APP_USE_PACKAGED_LAZY)
+         find_package(Microsoft.GSL 4.0.0 QUIET)
+@@ -20,7 +19,6 @@ if (DESKTOP_APP_USE_PACKAGED)
+         return()
+     endif()
+ endif()
+-]]
+ 
+ # https://gitlab.kitware.com/cmake/cmake/-/issues/25222
+ if (NOT EXISTS ${third_party_loc}/GSL/include)
+-- 
+2.41.0
+
diff --git a/gnu/packages/telegram.scm b/gnu/packages/telegram.scm
index 4814c22b6c..3208990c63 100644
--- a/gnu/packages/telegram.scm
+++ b/gnu/packages/telegram.scm
@@ -27,6 +27,7 @@ (define-module (gnu packages telegram)
   #:use-module (gnu packages assembly)
   #:use-module (gnu packages audio)
   #:use-module (gnu packages autotools)
+  #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
   #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
@@ -81,11 +82,11 @@ (define-module (gnu packages telegram)
   #:use-module (guix build-system python)
   #:use-module (guix build-system qt))
 
-(define %telegram-version "4.8.1")
+(define %telegram-version "4.11.8")
 
 (define libyuv-for-telegram-desktop
-  (let ((commit "77c2121f7e6b8e694d6e908bbbe9be24214097da")
-        (revision "2439"))
+  (let ((commit "04821d1e7d60845525e8db55c7bcd41ef5be9406")
+        (revision "2440"))
     (origin
       (method git-fetch)
       (uri (git-reference
@@ -96,67 +97,72 @@ (define libyuv-for-telegram-desktop
                   (git-version "0" revision commit)))
       (sha256
        (base32
-        "1b4k8yskr9ffl5k8s9i0af1gn1pavsfixla26vh8bij69rdr7f9c")))))
+        "1fsvc0f8mckrdzys8lnlnbw6676mjamm6p3ghr2h9liqfa83s6wg")))))
 
 (define cmake-helpers-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/cmake_helpers.git")
-          (commit "6ab5543b3dd1e40979d258e46d03376931b6c37b")))
+          (commit "c373a0a0141bbe146a9507f02b8515183748eb51")))
     (file-name
      (git-file-name "cmake-helpers-for-telegram-desktop" %telegram-version))
+    (patches
+     (search-patches "telegram-desktop-unbundle-gsl.patch"
+                     "telegram-desktop-unbundle-cppgir.patch"))
     (sha256
      (base32
-      "0y96mvzs113zh8bdw1h3i6l0pgwg93rigrday8kfdg4magz686k6"))))
+      "1wr624iqffgl48d8rnkb3ys16lyrc1gi9gh8wbwnskfidhf1av7a"))))
 
 (define codegen-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/codegen.git")
-          (commit "1a969faa0afb29d53af03e530775eccdfb8433f1")))
+          (commit "805b851d69444ab3659b619566d186d0be83dcd9")))
     (file-name
      (git-file-name "codegen-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "1xmw8dfm51p5g20rlmzqnr72a14ngyxwq09an8clf1v5s6mmwvak"))))
+      "030i0pnzlbnyvizmjzzj75ipaj2z6sgkzgv1w0n6k4x5f7jgx9hd"))))
 
 (define lib-base-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_base.git")
-          (commit "fd9adb30ee906ea02c125eaa58fcfae773fdc677")))
+          (commit "5432626ef2af59f55110c3bf17556d16c48a4ac3")))
     (file-name
      (git-file-name "lib-base-for-telegram-desktop" %telegram-version))
+    (patches
+     (search-patches "telegram-desktop-fix-lib-base-build.patch"))
     (sha256
      (base32
-      "1m760mcfvgzia53nrs6wvjn353jvzlzln7c9fkx2dhpkigiynz83"))))
+      "1h59jhl3zks502m0h0lg7wfk70yzjsr688g3pm097khd3n1ni2lk"))))
 
 (define lib-crl-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_crl.git")
-          (commit "3d7e1e1f1321c3defd21c01882d674e485ecd8df")))
+          (commit "078006d29af0002e6cd8c61a405cdeaf65b37142")))
     (file-name
      (git-file-name "lib-crl-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "06mzafnjpfr5ih297dh7bxm6bgpg0wy0gv2r2732n5szyrg9sdl6"))))
+      "18n88ghj3akpkxvllrh1rs19vd0d3xw87hd67qphr30b6ggqs9fd"))))
 
 (define lib-lottie-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_lottie.git")
-          (commit "3e9c2f1026e4b5aa3202fca4cc67ece36c7cebb2")))
+          (commit "1a700e5a0d7c3e2f617530354ff2a47c5c72bb4a")))
     (file-name
      (git-file-name "lib-lottie-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "0l57ibfij9xm4ww4s9cc63q1x8xzpc6ablwaji1krrn3xxksqdd4"))))
+      "18w35sz6k3wcv07v0szx3avpfdl0rjby6yqm1fzmx7fqw2jn6wpl"))))
 
 (define lib-qr-for-telegram-desktop
   (origin
@@ -187,24 +193,24 @@ (define lib-spellcheck-for-telegram-desktop
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_spellcheck.git")
-          (commit "ae89fefd239ecc47d4dab7ba29f9e230376a57d3")))
+          (commit "c97b3fe73ddfbc80c9ecacfbf2cda824e5b05ff5")))
     (file-name
      (git-file-name "lib-spellcheck-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "147xbbcza5q4wcdipk5jplajzkc48971kg2s7qv5jlz33sxkw1lq"))))
+      "0ir8waxz5l099s1qfjmp7vzlma1xl27fhanmyzfxxz4rik4b9biq"))))
 
 (define lib-storage-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_storage.git")
-          (commit "839609369d04615475cb1518636de3619106a917")))
+          (commit "de731885163bc1b3fe3095413453777ee89a8561")))
     (file-name
      (git-file-name "lib-storage-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "1l26h2fmqp9dcpr6pfvdd5sjb68j7yh0ms2lnr8na7jf5xqmkwwm"))))
+      "1crnh8awh6axydranlbbxphvphghqqbp8sgcg9gr2gsw22zm12pw"))))
 
 (define lib-tl-for-telegram-desktop
   (origin
@@ -223,12 +229,12 @@ (define lib-ui-for-telegram-desktop
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_ui.git")
-          (commit "37531086ec21a8569deddedb11b402f8a3157b90")))
+          (commit "fee301f94197d3351f2f20671c329b81540e63e2")))
     (file-name
      (git-file-name "lib-ui-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "0l4baalwdiwcwzn3wgrbyiaryi70lswillbpkzcjpavaa2pjg6b0"))))
+      "0db09qpw1kd3kpa6jj9jmsdq2r92gw5q2slxw5r9z6xm4w40q4vx"))))
 
 (define lib-webrtc-for-telegram-desktop
   (origin
@@ -247,28 +253,28 @@ (define lib-webview-for-telegram-desktop
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_webview.git")
-          (commit "f632fc84cbc62ae8abbbd05f81d472757a337c11")))
+          (commit "3495eb8dd8f4e2dab9493b4a698e5006fadbca47")))
     (file-name
      (git-file-name "lib-webview-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "0idsfkxq7l9kgyrhifys5l4jkhvbyxkgkp0qdq9218h7g0ldw84i"))))
+      "0nj72zng77xbizxwmhasdbnvr04z0hjjrw8pg4nyxjkm2027nfvq"))))
 
 (define tgcalls-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/TelegramMessenger/tgcalls.git")
-          (commit "2e2797648aac2588e7fe479c2e8b4455ec65c5e6")))
+          (commit "eb120ec4d347dd8ba561d8bbbf0858f20baae4ba")))
     (file-name
      (git-file-name "tgcalls-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "193m2gkvipijqbfd6a8mhg9nd63wlnshzgspk3pip57vk21l709z"))))
+      "1g0ix1abjmgfg7ymg0w0vdl57az2vdn6q5zfjkcisvi7sab7rfrl"))))
 
 (define-public webrtc-for-telegram-desktop
-  (let ((commit "0532942ac6176a66ef184fb728a4cbb02958fc0b")
-        (revision "389"))
+  (let ((commit "be153adaa363b2b13242466ad5b7b87f61301639")
+        (revision "390"))
     (hidden-package
      (package
        (name "webrtc-for-telegram-desktop")
@@ -284,7 +290,7 @@ (define-public webrtc-for-telegram-desktop
           (file-name
            (git-file-name name version))
           (sha256
-           (base32 "0fary99yl1ddk5zjpfy0pyb5brd268j41plcnvv9qjyf0wj9hf2k"))
+           (base32 "0q8n1px35srxmymwvqkk41b8vdmspwkp35v5i1dn2ijiyjkwa0ba"))
           (patches
            (search-patches
             ;; https://github.com/desktop-app/tg_owt/pull/123
@@ -399,6 +405,33 @@ (define cld3-for-telegram-desktop
     (base32
      "0ayrrhfdwrf4260h9fsirkhhfrcvc3qqnh6h9wj3ixij2lq0wwqb"))))
 
+(define libprisma-for-telegram-desktop
+  (origin
+   (method git-fetch)
+   (uri (git-reference
+         (url "https://github.com/desktop-app/libprisma")
+         (commit "629dc69fbffa5d63954c8e8909a26efdd98573b0")))
+   (file-name
+    (git-file-name "libprisma-for-telegram-desktop" %telegram-version))
+   (sha256
+    (base32
+     "1r952f6kgzknkffvyy5cnz97qh799x21m7mclwqycjp3gcf3csja"))))
+
+(define cppgir-for-telegram-desktop
+  (package
+    (inherit cppgir)
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+              (url "https://gitlab.com/mnauw/cppgir.git")
+              (commit "69ef481cba38e848554cc5403b8d4141d3c51335")))
+       (file-name
+        (git-file-name "cppgir-for-telegram-desktop" %telegram-version))
+       (sha256
+        (base32
+         "0l87h8mx0ri60493i19k0kh44ccy8k7zgb1m74sd001x4ilygv0v"))))))
+
 (define-public telegram-desktop
   (package
     (name "telegram-desktop")
@@ -414,7 +447,7 @@ (define-public telegram-desktop
        (file-name
         (git-file-name name version))
        (sha256
-        (base32 "0g47ffamh1csp79yzkv28v3qjkhjacj0c7pjf53n1ks80j5hc2j0"))
+        (base32 "00958hwmbmzlq6110bm5mnvxvdk1z03hc1d90iaasinhr32jjrp4"))
        (patches
         (search-patches
          ;; https://github.com/telegramdesktop/tdesktop/pull/24126
@@ -480,7 +513,13 @@ (define-public telegram-desktop
                       ("Telegram/lib_webrtc" #$lib-webrtc-for-telegram-desktop)
                       ("Telegram/lib_webview" #$lib-webview-for-telegram-desktop)
                       ("Telegram/ThirdParty/cld3" #$cld3-for-telegram-desktop)
+                      ("Telegram/ThirdParty/libprisma" #$libprisma-for-telegram-desktop)
                       ("Telegram/ThirdParty/tgcalls" #$tgcalls-for-telegram-desktop)))))
+               (add-after 'unpack-additional-sources 'patch-gir-ignore-paths
+                 (lambda _
+                   (substitute* "cmake/external/glib/generate_cppgir.cmake"
+                     (("\\$\\{cmake_helpers_loc\\}/external/glib/cppgir/data")
+                      (string-append #$(this-package-input "cppgir") "/share/cppgir")))))
                (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
@@ -493,13 +532,17 @@ (define-public telegram-desktop
     (inputs
      (list abseil-cpp-cxxstd17
            alsa-lib
+           boost
            c++-gsl
            crc32c
+           cppgir-for-telegram-desktop
+           expected-lite
            fcitx-qt5
            fcitx5-qt
            ffmpeg
            glib-next
            glibmm-next
+           gobject-introspection
            gtk+
            hime
            hunspell
-- 
2.41.0