about summary refs log tree commit diff
path: root/pkgs/by-name/gp/gpaste
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/gp/gpaste')
-rw-r--r--pkgs/by-name/gp/gpaste/fix-paths.patch16
-rw-r--r--pkgs/by-name/gp/gpaste/package.nix88
-rw-r--r--pkgs/by-name/gp/gpaste/wrapper.js5
3 files changed, 109 insertions, 0 deletions
diff --git a/pkgs/by-name/gp/gpaste/fix-paths.patch b/pkgs/by-name/gp/gpaste/fix-paths.patch
new file mode 100644
index 0000000000000..ebebc8a20bd66
--- /dev/null
+++ b/pkgs/by-name/gp/gpaste/fix-paths.patch
@@ -0,0 +1,16 @@
+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
++++ b/src/libgpaste/gpaste/gpaste-settings.c
+@@ -1039,7 +1039,10 @@ create_g_settings (void)
+     }
+     else
+     {
+-        return g_settings_new (G_PASTE_SETTINGS_NAME);
++        // library used by introspection requires schemas but we cannot set XDG_DATA_DIRS for the library
++        g_autoptr (GSettingsSchemaSource) schema_source = g_settings_schema_source_new_from_directory ("@gschemasCompiled@", NULL, FALSE, NULL);
++        g_autoptr (GSettingsSchema) schema = g_settings_schema_source_lookup (schema_source, G_PASTE_SETTINGS_NAME, FALSE);
++        return g_settings_new_full (schema, NULL, NULL);
+     }
+ }
+ 
diff --git a/pkgs/by-name/gp/gpaste/package.nix b/pkgs/by-name/gp/gpaste/package.nix
new file mode 100644
index 0000000000000..16da276b64b55
--- /dev/null
+++ b/pkgs/by-name/gp/gpaste/package.nix
@@ -0,0 +1,88 @@
+{ stdenv
+, lib
+, fetchurl
+, gjs
+, glib
+, gobject-introspection
+, gtk3
+, gtk4
+, gcr_4
+, libadwaita
+, meson
+, ninja
+, pango
+, pkg-config
+, vala
+, desktop-file-utils
+, wrapGAppsHook3
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  version = "45.1";
+  pname = "gpaste";
+
+  src = fetchurl {
+    url = "https://www.imagination-land.org/files/gpaste/GPaste-${finalAttrs.version}.tar.xz";
+    hash = "sha256-yYLoHn3/2xlefBeErnydNfkvtJva8/9f9JHhfschBpQ=";
+  };
+
+  patches = [
+    ./fix-paths.patch
+  ];
+
+  # TODO: switch to substituteAll with placeholder
+  # https://github.com/NixOS/nix/issues/1846
+  postPatch = ''
+    substituteInPlace src/libgpaste/gpaste/gpaste-settings.c \
+      --subst-var-by gschemasCompiled ${glib.makeSchemaPath (placeholder "out") "${finalAttrs.pname}-${finalAttrs.version}"}
+  '';
+
+  nativeBuildInputs = [
+    gobject-introspection
+    meson
+    ninja
+    pkg-config
+    vala
+    desktop-file-utils
+    wrapGAppsHook3
+  ];
+
+  buildInputs = [
+    gjs
+    glib
+    gtk3
+    gtk4
+    gcr_4
+    libadwaita
+    pango
+  ];
+
+  mesonFlags = [
+    "-Dcontrol-center-keybindings-dir=${placeholder "out"}/share/gnome-control-center/keybindings"
+    "-Ddbus-services-dir=${placeholder "out"}/share/dbus-1/services"
+    "-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 integration";
+    mainProgram = "gpaste-client";
+    license = licenses.bsd2;
+    platforms = platforms.linux;
+    maintainers = teams.gnome.members;
+  };
+})
diff --git a/pkgs/by-name/gp/gpaste/wrapper.js b/pkgs/by-name/gp/gpaste/wrapper.js
new file mode 100644
index 0000000000000..ea6a9cba6f6fb
--- /dev/null
+++ b/pkgs/by-name/gp/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;