about summary refs log tree commit diff
path: root/pkgs/by-name
diff options
context:
space:
mode:
authorBobby Rong <rjl931189261@126.com>2023-08-18 17:23:40 +0800
committerJan Tojnar <jtojnar@gmail.com>2023-11-21 08:41:54 +0100
commitce2351582390357818dea55b40ec423b52e106a4 (patch)
treef495c16fad9e756fcc8af24889d30779b4810bae /pkgs/by-name
parent449c35bd5ccd6c9bded59d30797e96a40968f9ad (diff)
loupe: init at 45.beta.1
https://gitlab.gnome.org/GNOME/loupe/-/commits/45.beta.1

Co-authored-by: 06kellyjac <dev@j-k.io>
Co-authored-by: Jan Tojnar <jtojnar@gmail.com>
Diffstat (limited to 'pkgs/by-name')
-rw-r--r--pkgs/by-name/lo/loupe/package.nix98
1 files changed, 98 insertions, 0 deletions
diff --git a/pkgs/by-name/lo/loupe/package.nix b/pkgs/by-name/lo/loupe/package.nix
new file mode 100644
index 0000000000000..2a94f23c8180b
--- /dev/null
+++ b/pkgs/by-name/lo/loupe/package.nix
@@ -0,0 +1,98 @@
+{ stdenv
+, lib
+, fetchurl
+, fetchpatch2
+, cargo
+, desktop-file-utils
+, itstool
+, meson
+, ninja
+, pkg-config
+, jq
+, moreutils
+, rustc
+, wrapGAppsHook4
+, gtk4
+, lcms2
+, libadwaita
+, libgweather
+, glycin-loaders
+, gnome
+}:
+
+stdenv.mkDerivation rec {
+  pname = "loupe";
+  version = "45.beta.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/loupe/${lib.versions.major version}/loupe-${version}.tar.xz";
+    hash = "sha256-uCvnrFgGksbPVjtX/+2X5KzlRYWzH9M0BKQGplB3Rr8=";
+  };
+
+  patches = [
+    # Enable glycin sandbox
+    # https://gitlab.gnome.org/GNOME/loupe/-/issues/252
+    (fetchpatch2 {
+      url = "https://gitlab.gnome.org/GNOME/loupe/-/commit/aa2b4d59409c92ee402c6a86cb7c02f06854bb8d.patch";
+      hash = "sha256-zKvXrPeIDGbK0RXcZoMkf2FAk+Do099kY7pt6KhFMEs=";
+    })
+
+    # Fix paths in glycin library
+    glycin-loaders.passthru.glycinPathsPatch
+  ];
+
+  nativeBuildInputs = [
+    cargo
+    desktop-file-utils
+    itstool
+    meson
+    ninja
+    pkg-config
+    jq
+    moreutils
+    rustc
+    wrapGAppsHook4
+  ];
+
+  buildInputs = [
+    gtk4
+    lcms2
+    libadwaita
+    libgweather
+  ];
+
+  postPatch = ''
+    # Nothing is installed to $datadir/glib-2.0/schemas.
+    # https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/280
+    substituteInPlace meson.build --replace \
+      "glib_compile_schemas: true," "glib_compile_schemas: false,"
+
+    # Replace hash of file we patch in vendored glycin.
+    jq \
+      --arg hash "$(sha256sum vendor/glycin/src/dbus.rs | cut -d' ' -f 1)" \
+      '.files."src/dbus.rs" = $hash' \
+      vendor/glycin/.cargo-checksum.json \
+      | sponge vendor/glycin/.cargo-checksum.json
+  '';
+
+  preFixup = ''
+    # Needed for the glycin crate to find loaders.
+    # https://gitlab.gnome.org/sophie-h/glycin/-/blob/0.1.beta.2/glycin/src/config.rs#L44
+    gappsWrapperArgs+=(
+      --prefix XDG_DATA_DIRS : "${glycin-loaders}/share"
+    )
+  '';
+
+  passthru.updateScript = gnome.updateScript {
+    packageName = "loupe";
+  };
+
+  meta = with lib; {
+    homepage = "https://gitlab.gnome.org/GNOME/loupe";
+    description = "A simple image viewer application written with GTK4 and Rust";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ jk ] ++ teams.gnome.members;
+    platforms = platforms.unix;
+    mainProgram = "loupe";
+  };
+}