Subject: [PATCH 1/3] gnu: webrtc-for-telegram-desktop: Use usrsctp from guix instead of from third-party.

From: Raghav Gururajan <[email-masked]>
Date: Wed, 28 Apr 2021 12:51:39 -0400

UsrSCTP is now available in Guix (f5e69549ba5d6efcd03f4f50f771a8a76ed73c5b).

* gnu/packages/telegram.scm (webrtc-for-telegram-desktop)
[snippet]: Remove usrsctp from keep list.
[phases](patch-cmake): New phase.
---
 gnu/packages/telegram.scm | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/telegram.scm b/gnu/packages/telegram.scm
index e6bfe6c4f2..cf5c173973 100644
--- a/gnu/packages/telegram.scm
+++ b/gnu/packages/telegram.scm
@@ -44,6 +44,7 @@
   #:use-module (gnu packages linux)
   #:use-module (gnu packages lxqt)
   #:use-module (gnu packages lua)
+  #:use-module (gnu packages networking)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages protobuf)
@@ -96,7 +97,7 @@
                      '( ;; Custom forks which are incompatible with the ones in Guix.
                        "abseil-cpp" "libsrtp" "openh264" "rnnoise"
                        ;; Not available in Guix.
-                       "pffft" "usrsctp"
+                       "pffft"
                        ;; Has cmake support files for libvpx input.
                        "libvpx")))
                 (with-directory-excursion "src/third_party"
@@ -124,9 +125,22 @@
                                                  "/src/third_party/libyuv")))
                   (copy-recursively libvpx-from libvpx-to)
                   (copy-recursively libyuv-from libyuv-to))
-                #t)))))
+                #t))
+            (add-after 'copy-inputs 'patch-cmake
+              (lambda* (#:key inputs #:allow-other-keys)
+                (substitute* "CMakeLists.txt"
+                  ;; Disable building of usrsctp as thirdparty,
+                  ;; as we removed its source.
+                  (("include\\(cmake/libusrsctp.cmake\\)") "")
+                  ;; Link to usrsctp that is provided as input,
+                  ;; instead of linking to usrsctp that is supossedly
+                  ;; built as thirdparty.
+                  (("tg_owt::libusrsctp") "usrsctp")
+                  ;; Disable exporting of usrsctp,
+                  ;; that is supossedly built as thirdparty.
+                  (("[ \t]*libusrsctp") "")))))))
        (native-inputs
-        `(("gcc" ,gcc-9) ; keep in line with telegram-desktop
+        `(("gcc" ,gcc-9)          ; keep in line with telegram-desktop
           ("perl" ,perl)
           ("pkg-config" ,pkg-config)
           ("python" ,python-wrapper)
@@ -161,6 +175,7 @@
           ("opus" ,opus)
           ("protobuf" ,protobuf)
           ("pulseaudio" ,pulseaudio)
+          ("usrsctp" ,usrsctp)
           ("x11" ,libx11)
           ("xext" ,libxext)
           ("xtst" ,libxtst)))
-- 
2.31.1