From da2f4404144dac9930faa3031e48fd8aae9053d1 Mon Sep 17 00:00:00 2001
From: nixo <nicolo@nixo.xyz>
Date: Wed, 20 Jan 2021 18:00:51 +0100
Subject: [PATCH v2 4/4] gnu: nheko: Update to 0.8.0.

* gnu/packages/messaging.scm (nheko): Update to 0.8.0.

[source snippet]: Remove third_party folder.
[arguments]: Remove -fpermissive flag, remove remove-Werror phase, add phase
wrap-program and unbundle-dependencies.
[inputs]: Add gst-plugins-base, gst-plugins-bad, libnice, qtkeychain,
and unbundle blurhash, cpp-httplib and single-application.
[native-inputs]: Add doxygen, graphviz used to build documentation.
[description]: Simplify by removing the long list, add new features.
(mtxclient): Update to 0.4.0.
[arguments]: Remove set-home phase.
---
 gnu/packages/messaging.scm | 92 +++++++++++++++++++++++---------------
 1 file changed, 55 insertions(+), 37 deletions(-)

diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index c585326124..db41e436d7 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -18,13 +18,13 @@
 ;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
 ;;; Copyright © 2019, 2020 Brett Gilio <brettg@gnu.org>
 ;;; Copyright © 2019, 2020 Timotej Lazar <timotej.lazar@araneo.si>
-;;; Copyright © 2020 Nicolò Balzarotti <nicolo@nixo.xyz>
+;;; Copyright © 2020, 2021 Nicolò Balzarotti <nicolo@nixo.xyz>
 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2020 Reza Alizadeh Majd <r.majd@pantherx.org>
 ;;; Copyright © 2020 Jonathan Brielmaier <jonathan.brielmaier@web.de>
 ;;; Copyright © 2020 Mason Hock <chaosmonk@riseup.net>
-;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
+;;; Copyright © 2020, 2021 Michael Rohleder <mike@rohleder.de>
 ;;; Copyright © 2020 Raghav Gururajan <raghavgururajan@disroot.org>
 ;;; Copyright © 2020 Robert Karszniewicz <avoidr@posteo.de>
 ;;;
@@ -2227,7 +2227,7 @@ QMatrixClient project.")
 (define-public mtxclient
   (package
     (name "mtxclient")
-    (version "0.3.1")
+    (version "0.4.0")
     (source
      (origin
        (method git-fetch)
@@ -2236,7 +2236,7 @@ QMatrixClient project.")
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1dg4dq20g0ah62j5s3gpsxqq4ny7lxkxdxa9q6g54hdwkrb9ms7x"))))
+        (base32 "1x820rcfz5r203dc8a0rzavcjjx10fsv1dicqg65m6kxx1w95j5r"))))
     (arguments
      `(#:configure-flags
        (list
@@ -2249,12 +2249,6 @@ QMatrixClient project.")
              (substitute* "CMakeLists.txt"
                (("add_test\\((BasicConnectivity|ClientAPI|MediaAPI|Encryption|Pushrules)")
                 "# add_test"))
-             #t))
-         (add-before 'configure 'set-home
-           (lambda _
-             ;; Tries to create package registry file
-             ;; So, set HOME.
-             (setenv "HOME" "/tmp")
              #t)))))
     (build-system cmake-build-system)
     (inputs
@@ -2277,7 +2271,7 @@ for the Matrix protocol.  It is built on to of @code{Boost.Asio}.")
 (define-public nheko
   (package
     (name "nheko")
-    (version "0.7.2")
+    (version "0.8.0")
     (source
      (origin
        (method git-fetch)
@@ -2286,30 +2280,64 @@ for the Matrix protocol.  It is built on to of @code{Boost.Asio}.")
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1cbhgaf9klgxdirrxj571fqwspm0byl75c1xc40l727a6qswvp7s"))))
+        (base32 "00d6wx3lcgbks74jkdyifqxf8nlravqh88fyljd0sy7kzbah9msf"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           (delete-file-recursively "third_party")
+           #t))))
     (arguments
      `(#:tests? #f                      ;no test target
        #:configure-flags
-       (list
-        "-DCMAKE_BUILD_TYPE=Release"
-        "-DCMAKE_CXX_FLAGS=-fpermissive")
+       '("-DCMAKE_BUILD_TYPE=Release"
+         "-DBUILD_DOCS=ON"
+         ;; Fix required because we are using a static SingleApplication
+         "-DCMAKE_CXX_FLAGS= \"-DQAPPLICATION_CLASS=QApplication\" "
+         ;; Compile Qml will make Nheko faster, but you will need to recompile
+         ;; it, when you update Qt.  That's fine for us.
+         "-DCOMPILE_QML=ON")
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'remove-Werror
-           (lambda _
-             (substitute* "CMakeLists.txt"
-               (("-Werror") ""))
+         (add-after 'unpack 'unbundle-dependencies
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((single-app (assoc-ref inputs "single-application")))
+               (substitute* "CMakeLists.txt"
+                 ;; Remove include and source dirs,replace with the correct one
+                 (("third_party/blurhash/blurhash.cpp") "")
+                 (("third_party/cpp-httplib-0.5.12")
+                  (string-append "\"" single-app "/include\""))
+                 (("add_subdirectory.*third_party/SingleApplication.*") "")
+                 ;; Link using the correct static/shared libs
+                 (("SingleApplication::SingleApplication")
+                  (string-append
+                   ;; Dynamic libraries
+                   "httplib" "\n" "blurhash" "\n"
+                   ;; Static library
+                   single-app "/lib/libSingleApplication.a"))))
              #t))
          (add-after 'unpack 'fix-determinism
            (lambda _
              ;; Make Qt deterministic.
              (setenv "QT_RCC_SOURCE_DATE_OVERRIDE" "1")
-             #t)))))
+             #t))
+         (add-after 'install 'wrap-program
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out"))
+                   (gst-plugin-path (getenv "GST_PLUGIN_SYSTEM_PATH")))
+               (wrap-program (string-append out "/bin/nheko")
+                 `("GST_PLUGIN_SYSTEM_PATH" ":" prefix (,gst-plugin-path)))
+               #t))))))
     (build-system qt-build-system)
     (inputs
      `(("boost" ,boost)
+       ("blurhash" ,blurhash)
+       ("cpp-httplib" ,cpp-httplib)
        ("cmark" ,cmark)
+       ("gst-plugins-base" ,gst-plugins-base)
+       ("gst-plugins-bad" ,gst-plugins-bad)   ; sdp & webrtc for voip
+       ("gst-plugins-good" ,gst-plugins-good) ; rtpmanager for voip
        ("json-modern-cxx" ,json-modern-cxx)
+       ("libnice" ,libnice)                   ; for voip
        ("libolm" ,libolm)
        ("lmdb" ,lmdb)
        ("lmdbxx" ,lmdbxx)
@@ -2317,15 +2345,19 @@ for the Matrix protocol.  It is built on to of @code{Boost.Asio}.")
        ("openssl" ,openssl)
        ("qtbase" ,qtbase)
        ("qtdeclarative" ,qtdeclarative)
+       ("qtkeychain" ,qtkeychain)
        ("qtgraphicaleffects" ,qtgraphicaleffects)
        ("qtmultimedia" ,qtmultimedia)
        ("qtquickcontrols2" ,qtquickcontrols2)
        ("qtsvg" ,qtsvg)
        ("spdlog" ,spdlog)
+       ("single-application" ,single-application-qt5)
        ("tweeny" ,tweeny)
        ("zlib" ,zlib)))
     (native-inputs
-     `(("pkg-config" ,pkg-config)
+     `(("doxygen" ,doxygen)
+       ("graphviz" ,graphviz)
+       ("pkg-config" ,pkg-config)
        ("qtlinguist" ,qttools)))
     (home-page "https://github.com/Nheko-Reborn/nheko")
     (synopsis "Desktop client for Matrix using Qt and C++14")
@@ -2333,22 +2365,8 @@ for the Matrix protocol.  It is built on to of @code{Boost.Asio}.")
 Matrix protocol that feels more like a mainstream chat app and less like an IRC
 client.
 
-There is support for:
-@itemize
-@item E2E encryption (text messages only: attachments are currently sent unencrypted).
-@item User registration.
-@item Creating, joining & leaving rooms.
-@item Sending & receiving invites.
-@item Sending & receiving files and emoji.
-@item Typing notifications.
-@item Username auto-completion.
-@item Message & mention notifications.
-@item Redacting messages.
-@item Read receipts.
-@item Basic communities support.
-@item Room switcher (@key{ctrl-K}).
-@item Light, Dark & System themes.
-@end itemize")
+Many matrix features are supported, including user registration, rooms, typing
+notification, emojis, E2E encryption, and voip calls.")
     (license license:gpl3+)))
 
 (define-public quaternion
-- 
2.29.2

