Subject: [bug#44730] [GAJIM]: Fix loading of installed plugins

From: Raghav Gururajan <[email-masked]>
Date: Wed, 18 Nov 2020 15:50:14 -0500

Hello Guix!

Please find the attached patch to fix plugins issue in Gajim.

@Julien
Will you be able to push this patch? This patch is a follow-up of #43575.

Thank you!

Regards,
RG.
From efa57cb42f620009b13f27774167e452d40a318b Mon Sep 17 00:00:00 2001
From: Raghav Gururajan <[email-masked]>
Date: Wed, 18 Nov 2020 15:33:24 -0500
Subject: [PATCH] gnu: gajim: Fix loading of os-installed plugins.

* gnu/packages/messaging.scm (gajim) [patches]: Add gajim-plugins-os.patch.
[arguments]<#:phases>['add-plugins-dir]: Remove phase.
[native-search-paths]: Modify.
* gnu/packages/patches/gajim-plugins-os.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
 gnu/local.mk                                |  1 +
 gnu/packages/messaging.scm                  | 14 +++---------
 gnu/packages/patches/gajim-plugins-os.patch | 25 +++++++++++++++++++++
 3 files changed, 29 insertions(+), 11 deletions(-)
 create mode 100644 gnu/packages/patches/gajim-plugins-os.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 217c05eab6..53bda11011 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -991,6 +991,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/freedink-engine-fix-sdl-hints.patch	\
   %D%/packages/patches/freeimage-unbundle.patch		\
   %D%/packages/patches/fuse-overlapping-headers.patch				\
+  %D%/packages/patches/gajim-plugins-os.patch				\
   %D%/packages/patches/ganeti-deterministic-manual.patch	\
   %D%/packages/patches/ganeti-disable-version-symlinks.patch	\
   %D%/packages/patches/ganeti-drbd-compat.patch			\
diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index 624ad72c23..714cfa27d6 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -742,6 +742,8 @@ of xmpppy.")
         (string-append "https://gajim.org/downloads/"
                        (version-major+minor version)
                        "/gajim-" version ".tar.gz"))
+       (patches
+        (search-patches "gajim-plugins-os.patch"))
        (sha256
         (base32 "1gfcp3b5nq43xxz5my8vfhfxnnli726j3hzcgwh9fzrzzd9ic3gx"))))
     (build-system python-build-system)
@@ -756,16 +758,6 @@ of xmpppy.")
         (guix build utils))
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'add-plugin-dirs
-           (lambda _
-             (substitute* "gajim/common/configpaths.py"
-               (("_paths\\['PLUGINS_USER'\\]\\]")
-                "_paths['PLUGINS_USER']] + \
-([os.getenv('GAJIM_PLUGIN_PATH')] \
-if os.getenv('GAJIM_PLUGIN_PATH') \
-and Path(os.getenv('GAJIM_PLUGIN_PATH')).is_dir() \
-else [])"))
-             #t))
          (replace 'check
            (lambda _
              ;; Tests require a running X server.
@@ -795,7 +787,7 @@ else [])"))
     (native-search-paths
      (list
       (search-path-specification
-       (variable "GAJIM_PLUGIN_PATH")
+       (variable "PLUGINS_OS")
        (separator #f)                   ;single entry
        (files
         (list
diff --git a/gnu/packages/patches/gajim-plugins-os.patch b/gnu/packages/patches/gajim-plugins-os.patch
new file mode 100644
index 0000000000..39c22803f7
--- /dev/null
+++ b/gnu/packages/patches/gajim-plugins-os.patch
@@ -0,0 +1,25 @@
+From c1974d64e5b8f03dc5fc9564f4dd8cff5f2cbc9b Mon Sep 17 00:00:00 2001
+From: Raghav Gururajan <[email-masked]>
+Date: Wed, 18 Nov 2020 15:12:45 -0500
+Subject: [PATCH] [PATCH]: Fix loading of plugins installed via OS's package
+ manager.
+
+---
+ gajim/common/configpaths.py | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/gajim/common/configpaths.py b/gajim/common/configpaths.py
+index 0ac879314..57b99f955 100644
+--- a/gajim/common/configpaths.py
++++ b/gajim/common/configpaths.py
+@@ -47,6 +47,7 @@ def get_plugin_dirs() -> List[Path]:
+         return [Path(_paths['PLUGINS_BASE']),
+                 Path('/app/plugins')]
+     return [Path(_paths['PLUGINS_BASE']),
++            Path(os.getenv['PLUGINS_OS']),
+             Path(_paths['PLUGINS_USER'])]
+ 
+ 
+-- 
+2.29.2
+
-- 
2.29.2