From e75decf46b045e79e80eed06301fa74ac15c583c Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 8 Dec 2023 22:58:29 +0100 Subject: gnome.gpaste: Fix typelib path adjustment I attempted to fix this in af9e3ddc1da4c96d35b326d20ba09cedb1a5ac3b but it looks like my mental model of module loader was incorrect so the fix there was insufficient. Therefore the only option appears to be using a top-level await with a dynamic import. To avoid having to figure out which imports need to be dynamicized, we just wrap the whole entrypoints. --- pkgs/desktops/gnome/misc/gpaste/default.nix | 18 +++++++--- pkgs/desktops/gnome/misc/gpaste/fix-paths.patch | 45 ------------------------- pkgs/desktops/gnome/misc/gpaste/wrapper.js | 5 +++ 3 files changed, 19 insertions(+), 49 deletions(-) create mode 100644 pkgs/desktops/gnome/misc/gpaste/wrapper.js (limited to 'pkgs/desktops/gnome/misc') diff --git a/pkgs/desktops/gnome/misc/gpaste/default.nix b/pkgs/desktops/gnome/misc/gpaste/default.nix index 2051f19a37be0..2f66d742f969c 100644 --- a/pkgs/desktops/gnome/misc/gpaste/default.nix +++ b/pkgs/desktops/gnome/misc/gpaste/default.nix @@ -35,10 +35,6 @@ stdenv.mkDerivation rec { # TODO: switch to substituteAll with placeholder # https://github.com/NixOS/nix/issues/1846 postPatch = '' - substituteInPlace src/gnome-shell/extension.js \ - --subst-var-by typelibPath "${placeholder "out"}/lib/girepository-1.0" - substituteInPlace src/gnome-shell/prefs.js \ - --subst-var-by typelibPath "${placeholder "out"}/lib/girepository-1.0" substituteInPlace src/libgpaste/gpaste/gpaste-settings.c \ --subst-var-by gschemasCompiled ${glib.makeSchemaPath (placeholder "out") "${pname}-${version}"} ''; @@ -69,6 +65,20 @@ stdenv.mkDerivation rec { "-Dsystemd-user-unit-dir=${placeholder "out"}/etc/systemd/user" ]; + postInstall = '' + # We do not have central location to install typelibs to, + # let’s ensure GNOME Shell can still find them. + extensionDir="$out/share/gnome-shell/extensions/GPaste@gnome-shell-extensions.gnome.org" + mv "$extensionDir/"{extension,.extension-wrapped}.js + mv "$extensionDir/"{prefs,.prefs-wrapped}.js + substitute "${./wrapper.js}" "$extensionDir/extension.js" \ + --subst-var-by originalName "extension" \ + --subst-var-by typelibPath "${placeholder "out"}/lib/girepository-1.0" + substitute "${./wrapper.js}" "$extensionDir/prefs.js" \ + --subst-var-by originalName "prefs" \ + --subst-var-by typelibPath "${placeholder "out"}/lib/girepository-1.0" + ''; + meta = with lib; { homepage = "https://github.com/Keruspe/GPaste"; description = "Clipboard management system with GNOME 3 integration"; diff --git a/pkgs/desktops/gnome/misc/gpaste/fix-paths.patch b/pkgs/desktops/gnome/misc/gpaste/fix-paths.patch index ef782ce374a8a..ebebc8a20bd66 100644 --- a/pkgs/desktops/gnome/misc/gpaste/fix-paths.patch +++ b/pkgs/desktops/gnome/misc/gpaste/fix-paths.patch @@ -1,48 +1,3 @@ -diff --git a/src/gnome-shell/__nix-prepend-search-paths.js b/src/gnome-shell/__nix-prepend-search-paths.js -new file mode 100644 -index 00000000..e8e20c67 ---- /dev/null -+++ b/src/gnome-shell/__nix-prepend-search-paths.js -@@ -0,0 +1,3 @@ -+import GIRepository from 'gi://GIRepository'; -+ -+GIRepository.Repository.prepend_search_path('@typelibDir@'); -diff --git a/src/gnome-shell/extension.js b/src/gnome-shell/extension.js -index cb862a30..980767c9 100644 ---- a/src/gnome-shell/extension.js -+++ b/src/gnome-shell/extension.js -@@ -4,6 +4,8 @@ - * Copyright (c) 2010-2023, Marc-Antoine Perennou - */ - -+import './__nix-prepend-search-paths.js'; -+ - 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/meson.build b/src/gnome-shell/meson.build -index 86cbb0b2..80fc4d67 100644 ---- a/src/gnome-shell/meson.build -+++ b/src/gnome-shell/meson.build -@@ -1,4 +1,5 @@ - shell_extension_files = [ -+ '__nix-prepend-search-paths.js', - 'aboutItem.js', - 'actionButton.js', - 'actionButtonActor.js', -diff --git a/src/gnome-shell/prefs.js b/src/gnome-shell/prefs.js -index 4c0d9bde..58f54f9a 100644 ---- a/src/gnome-shell/prefs.js -+++ b/src/gnome-shell/prefs.js -@@ -4,6 +4,8 @@ - * Copyright (c) 2010-2023, Marc-Antoine Perennou - */ - -+import './__nix-prepend-search-paths.js'; -+ - 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 diff --git a/pkgs/desktops/gnome/misc/gpaste/wrapper.js b/pkgs/desktops/gnome/misc/gpaste/wrapper.js new file mode 100644 index 0000000000000..ea6a9cba6f6fb --- /dev/null +++ b/pkgs/desktops/gnome/misc/gpaste/wrapper.js @@ -0,0 +1,5 @@ +import GIRepository from 'gi://GIRepository'; + +GIRepository.Repository.prepend_search_path('@typelibDir@'); + +export default (await import('./.@originalName@-wrapped.js')).default; -- cgit 1.4.1