Skip to content

Commit

Permalink
libjxl: build gdk-pixbuf loader and thumbnailer
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzsyyy committed Jan 18, 2024
1 parent bae0615 commit 2f5cb57
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions pkgs/development/libraries/libjxl/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ stdenv, lib, fetchFromGitHub
{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, brotli
, cmake
Expand All @@ -9,8 +11,10 @@
, libjpeg
, libpng
, libwebp
, openexr
, gdk-pixbuf
, openexr_3
, pkg-config
, makeWrapper
, zlib
, buildDocs ? true
, asciidoc
Expand All @@ -19,6 +23,11 @@
, python3
}:

let
inherit (gdk-pixbuf) moduleDir;
loadersPath = "${gdk-pixbuf.binaryDir}/jxl-loaders.cache";
in

stdenv.mkDerivation rec {
pname = "libjxl";
version = "0.8.2";
Expand Down Expand Up @@ -47,6 +56,8 @@ stdenv.mkDerivation rec {
cmake
gtest
pkg-config
gdk-pixbuf
makeWrapper
] ++ lib.optionals buildDocs [
asciidoc
doxygen
Expand Down Expand Up @@ -79,7 +90,8 @@ stdenv.mkDerivation rec {
libjpeg
libpng
libwebp
openexr
gdk-pixbuf
openexr_3
zlib
];

Expand All @@ -106,17 +118,30 @@ stdenv.mkDerivation rec {
# Viewer tools for evaluation.
# "-DJPEGXL_ENABLE_VIEWERS=ON"

# TODO: Update this package to enable this (overridably via an option):
# Enable plugins, such as:
# * the `gdk-pixbuf` one, which allows applications like `eog` to load jpeg-xl files
# * the `gimp` one, which allows GIMP to load jpeg-xl files
# "-DJPEGXL_ENABLE_PLUGINS=ON"
"-DJPEGXL_ENABLE_PLUGINS=ON"
] ++ lib.optionals stdenv.hostPlatform.isStatic [
"-DJPEGXL_STATIC=ON"
] ++ lib.optionals stdenv.hostPlatform.isAarch32 [
"-DJPEGXL_FORCE_NEON=ON"
];

postPatch = ''
substituteInPlace plugins/gdk-pixbuf/jxl.thumbnailer \
--replace '/usr/bin/gdk-pixbuf-thumbnailer' "$out/libexec/gdk-pixbuf-thumbnailer-jxl"
'';

postInstall = ''
GDK_PIXBUF_MODULEDIR="$out/${moduleDir}" \
GDK_PIXBUF_MODULE_FILE="$out/${loadersPath}" \
gdk-pixbuf-query-loaders --update-cache
mkdir -p "$out/bin"
makeWrapper ${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer "$out/libexec/gdk-pixbuf-thumbnailer-jxl" \
--set GDK_PIXBUF_MODULE_FILE "$out/${loadersPath}" \
'';

LDFLAGS = lib.optionalString stdenv.hostPlatform.isRiscV "-latomic";
CXXFLAGS = lib.optionalString stdenv.hostPlatform.isAarch32 "-mfp16-format=ieee";

Expand Down

0 comments on commit 2f5cb57

Please sign in to comment.