guix_mirror_bot pushed a commit to branch master
in repository guix.

commit ca09756d6eaf6629ea2391e36c1db88014ffbff3
Author: Attila Lendvai <[email protected]>
AuthorDate: Mon Nov 2 13:41:00 2026 +0100

    gnu: gpaste: Fix shell extension typelib lookup.
    
    Extensions in Gnome Shell v45+ are now ES modules, so their static imports 
are
    resolved before the module body runs.  It became too late to prepend the
    typelib search path inside extension.js and prefs.js.
    
    This fix installs a wrapper that prepends the package's lib/girepository-1.0
    to the GIRepository search path, and only then dynamically imports the real
    module, so the whole module graph is loaded once the path is in place.
    
    * gnu/packages/gnome-xyz.scm (gpaste)[#:phases]
    <fix-introspection-install-dir>: Rename to …
    <fix-settings-schema-path>: … this.  Only fix @gschemasCompiled@.
    <wrap-gnome-shell-extension>: New phase.
    * gnu/packages/patches/gpaste-fix-paths.patch: Remove hunks prepending
    typelib search paths.
    
    Fixes: guix/guix#10998
    Signed-off-by: Liliana Marie Prikler <[email protected]>
    Merges: guix/guix#12269
---
 gnu/packages/gnome-xyz.scm                  | 40 ++++++++++++++++++++++++-----
 gnu/packages/patches/gpaste-fix-paths.patch | 31 ++--------------------
 2 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/gnu/packages/gnome-xyz.scm b/gnu/packages/gnome-xyz.scm
index bc87f67c232..8e31fe05711 100644
--- a/gnu/packages/gnome-xyz.scm
+++ b/gnu/packages/gnome-xyz.scm
@@ -1367,15 +1367,43 @@ dark, switch backgrounds and run custom commands at 
sunset and sunrise.")
                              #$output "/etc/systemd/user"))
            #:phases
            #~(modify-phases %standard-phases
-               (add-after 'unpack 'fix-introspection-install-dir
+               (add-after 'unpack 'fix-settings-schema-path
                  (lambda _
                    (substitute* "src/libgpaste/gpaste/gpaste-settings.c"
                      (("@gschemasCompiled@")
-                      (string-append #$output "/share/glib-2.0/schemas/")))
-                   (substitute* '("src/gnome-shell/extension.js"
-                                  "src/gnome-shell/prefs.js")
-                     (("@typelibDir@")
-                      (string-append #$output "/lib/girepository-1.0/"))))))))
+                      (string-append #$output "/share/glib-2.0/schemas/")))))
+               ;; Extensions in Gnome Shell v45+ are now ES modules, so their
+               ;; static imports are resolved before the module body runs.
+               ;;
+               ;; Let's install a wrapper that prepends the package's
+               ;; lib/girepository-1.0 to the GIRepository search path, and
+               ;; only then dynamically imports the real module, so the whole
+               ;; module graph is loaded once the path is in place.
+               (add-after 'install 'wrap-gnome-shell-extension
+                 (lambda _
+                   (define (wrap file)
+                     ;; Move FILE aside and replace it with a module that
+                     ;; prepends the typelib search path before importing
+                     ;; the real module.
+                     (let ((name (basename file ".js")))
+                       (rename-file file (string-append "." name 
"-wrapped.js"))
+                       (call-with-output-file file
+                         (lambda (port)
+                           (display
+                            (string-append
+                             "import GIRepository from 'gi://GIRepository';\n"
+                             "GIRepository.Repository.dup_default()"
+                             ".prepend_search_path('"
+                             #$output "/lib/girepository-1.0');\n"
+                             "export default (await import('./."
+                             name "-wrapped.js')).default;\n")
+                            port)))))
+                   (let ((extension-dir
+                          (string-append
+                           #$output "/share/gnome-shell/extensions/"
+                           "[email protected]")))
+                     (with-directory-excursion extension-dir
+                       (for-each wrap '("extension.js" "prefs.js")))))))))
     (home-page "https://github.com/Keruspe/GPaste";)
     (synopsis "Clipboard management system for GNOME Shell")
     (description "GPaste is a clipboard manager, a tool which allows you to
diff --git a/gnu/packages/patches/gpaste-fix-paths.patch 
b/gnu/packages/patches/gpaste-fix-paths.patch
index 49e201d1193..fee32527524 100644
--- a/gnu/packages/patches/gpaste-fix-paths.patch
+++ b/gnu/packages/patches/gpaste-fix-paths.patch
@@ -1,34 +1,7 @@
-Adjust search paths so GIR typelibs and GLib schemas are found.
+Adjust search paths so GLib schemas are found.
+
 Adapted from Nixpkgs: 
<https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name/gp/gpaste>.
 
-diff --git a/src/gnome-shell/extension.js b/src/gnome-shell/extension.js
-index cb862a30..6c24175b 100644
---- a/src/gnome-shell/extension.js
-+++ b/src/gnome-shell/extension.js
-@@ -4,6 +4,9 @@
-  * Copyright (c) 2010-2023, Marc-Antoine Perennou <[email protected]>
-  */
- 
-+import GIRepository from 'gi://GIRepository';
-+GIRepository.Repository.dup_default().prepend_search_path('@typelibDir@');
-+
- import * as Main from 'resource:///org/gnome/shell/ui/main.js';
- import {Extension, gettext as _} from 
'resource:///org/gnome/shell/extensions/extension.js';
- 
-diff --git a/src/gnome-shell/prefs.js b/src/gnome-shell/prefs.js
-index 4c0d9bde..6a376b32 100644
---- a/src/gnome-shell/prefs.js
-+++ b/src/gnome-shell/prefs.js
-@@ -4,6 +4,9 @@
-  * Copyright (c) 2010-2023, Marc-Antoine Perennou <[email protected]>
-  */
- 
-+import GIRepository from 'gi://GIRepository';
-+GIRepository.Repository.prepend_search_path('@typelibDir@');
-+
- import { ExtensionPreferences, gettext as _ } from 
'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
- 
- import GPasteGtk from 'gi://GPasteGtk?version=4';
 diff --git a/src/libgpaste/gpaste/gpaste-settings.c 
b/src/libgpaste/gpaste/gpaste-settings.c
 index 830f5e0b..c8df0e11 100644
 --- a/src/libgpaste/gpaste/gpaste-settings.c

Reply via email to