Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libjxl: build gdk-pixbuf loader and thumbnailer #299988

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions pkgs/development/libraries/libjxl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@
, libjpeg
, libpng
, libwebp
, gdk-pixbuf
, openexr_3
, pkg-config
, makeWrapper
, zlib
, asciidoc
, graphviz
, doxygen
, python3
, lcms2
}:

let
loadersPath = "${gdk-pixbuf.binaryDir}/jxl-loaders.cache";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also include the version number to make chance of conflict even lower but this looks good to me.

in

stdenv.mkDerivation rec {
pname = "libjxl";
version = "0.9.1";
Expand All @@ -37,6 +44,8 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [
cmake
pkg-config
gdk-pixbuf
makeWrapper
asciidoc
doxygen
python3
Expand All @@ -63,12 +72,14 @@ stdenv.mkDerivation rec {
# conclusively in its README or otherwise; they can best be determined
# by checking the CMake output for "Could NOT find".
buildInputs = [
lcms2
giflib
gperftools # provides `libtcmalloc`
gtest
libjpeg
libpng
libwebp
gdk-pixbuf
openexr_3
zlib
];
Expand Down Expand Up @@ -96,17 +107,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/${gdk-pixbuf.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}"
'';

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

# FIXME x86_64-darwin:
Expand Down