diff --git a/pkgs/desktops/gnome/misc/gpaste/default.nix b/pkgs/desktops/gnome/misc/gpaste/default.nix index 2051f19a37be..2f66d742f969 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 ef782ce374a8..ebebc8a20bd6 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 000000000000..ea6a9cba6f6f --- /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;