2021-06-26 16:12:04 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
fetchFromGitHub,
|
|
|
|
brotli,
|
|
|
|
cmake,
|
|
|
|
giflib,
|
|
|
|
gperftools,
|
|
|
|
gtest,
|
2022-01-09 01:59:14 +00:00
|
|
|
libhwy,
|
2021-06-26 16:12:04 +00:00
|
|
|
libjpeg,
|
|
|
|
libpng,
|
|
|
|
libwebp,
|
2024-03-29 12:41:25 +00:00
|
|
|
gdk-pixbuf,
|
2024-01-11 11:33:48 +00:00
|
|
|
openexr_3,
|
2021-06-26 16:12:04 +00:00
|
|
|
pkg-config,
|
2024-03-29 12:41:25 +00:00
|
|
|
makeWrapper,
|
2021-06-26 16:12:04 +00:00
|
|
|
zlib,
|
2022-06-05 04:51:44 +00:00
|
|
|
asciidoc,
|
|
|
|
graphviz,
|
|
|
|
doxygen,
|
|
|
|
python3,
|
2024-03-29 12:41:25 +00:00
|
|
|
lcms2,
|
2024-09-29 00:18:59 +00:00
|
|
|
enablePlugins ? true,
|
2021-06-26 16:12:04 +00:00
|
|
|
}:
|
|
|
|
|
2024-03-29 12:41:25 +00:00
|
|
|
let
|
|
|
|
loadersPath = "${gdk-pixbuf.binaryDir}/jxl-loaders.cache";
|
|
|
|
in
|
|
|
|
|
2021-06-26 16:12:04 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libjxl";
|
2024-09-21 18:09:13 +00:00
|
|
|
version = "0.11.0";
|
2021-06-26 16:12:04 +00:00
|
|
|
|
2022-08-03 00:02:21 +00:00
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
"dev"
|
|
|
|
];
|
|
|
|
|
2021-06-26 16:12:04 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "libjxl";
|
|
|
|
repo = "libjxl";
|
2021-09-05 16:04:18 +00:00
|
|
|
rev = "v${version}";
|
2024-09-21 18:09:13 +00:00
|
|
|
hash = "sha256-lBc0zP+f44YadwOU9+I+YYWzTrAg7FSfF3IQuh4LjM4=";
|
2021-06-26 16:12:04 +00:00
|
|
|
# There are various submodules in `third_party/`.
|
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2024-01-13 08:15:37 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
2021-06-26 16:12:04 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
pkg-config
|
2024-03-29 12:41:25 +00:00
|
|
|
gdk-pixbuf
|
|
|
|
makeWrapper
|
2022-06-05 04:51:44 +00:00
|
|
|
asciidoc
|
|
|
|
doxygen
|
|
|
|
python3
|
2021-06-26 16:12:04 +00:00
|
|
|
];
|
|
|
|
|
2024-01-21 03:07:31 +00:00
|
|
|
depsBuildBuild = [
|
2022-06-25 19:00:39 +00:00
|
|
|
graphviz
|
|
|
|
];
|
|
|
|
|
2021-06-26 16:12:04 +00:00
|
|
|
# Functionality not currently provided by this package
|
|
|
|
# that the cmake build can apparently use:
|
|
|
|
# OpenGL/GLUT (for Examples -> comparison with sjpeg)
|
|
|
|
# viewer (see `cmakeFlags`)
|
|
|
|
# plugins like for GDK and GIMP (see `cmakeFlags`)
|
|
|
|
|
|
|
|
# Vendored libraries:
|
|
|
|
# `libjxl` currently vendors many libraries as git submodules that they
|
|
|
|
# might patch often (e.g. test/gmock, see
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/103160#discussion_r519487734).
|
|
|
|
# When it has stabilised in the future, we may want to tell the build
|
|
|
|
# to use use nixpkgs system libraries.
|
|
|
|
|
|
|
|
# As of writing, libjxl does not point out all its dependencies
|
|
|
|
# conclusively in its README or otherwise; they can best be determined
|
|
|
|
# by checking the CMake output for "Could NOT find".
|
|
|
|
buildInputs = [
|
2024-03-29 12:41:25 +00:00
|
|
|
lcms2
|
2021-06-26 16:12:04 +00:00
|
|
|
giflib
|
|
|
|
gperftools # provides `libtcmalloc`
|
2024-01-13 08:15:37 +00:00
|
|
|
gtest
|
2021-06-26 16:12:04 +00:00
|
|
|
libjpeg
|
|
|
|
libpng
|
|
|
|
libwebp
|
2024-03-29 12:41:25 +00:00
|
|
|
gdk-pixbuf
|
2024-01-11 11:33:48 +00:00
|
|
|
openexr_3
|
2021-06-26 16:12:04 +00:00
|
|
|
zlib
|
|
|
|
];
|
|
|
|
|
2022-06-12 07:28:52 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
brotli
|
|
|
|
libhwy
|
|
|
|
];
|
|
|
|
|
2021-06-26 16:12:04 +00:00
|
|
|
cmakeFlags =
|
|
|
|
[
|
|
|
|
# For C dependencies like brotli, which are dynamically linked,
|
|
|
|
# we want to use the system libraries, so that we don't have to care about
|
|
|
|
# installing their .so files generated by this build.
|
|
|
|
# The other C++ dependencies are statically linked in, so there
|
|
|
|
# using the vendorered ones is easier.
|
|
|
|
"-DJPEGXL_FORCE_SYSTEM_BROTLI=ON"
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2022-01-09 01:59:14 +00:00
|
|
|
# Use our version of highway, though it is still statically linked in
|
|
|
|
"-DJPEGXL_FORCE_SYSTEM_HWY=ON"
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2023-03-01 06:24:14 +00:00
|
|
|
# Use our version of gtest
|
|
|
|
"-DJPEGXL_FORCE_SYSTEM_GTEST=ON"
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2021-06-26 16:12:04 +00:00
|
|
|
# TODO: Update this package to enable this (overridably via an option):
|
|
|
|
# Viewer tools for evaluation.
|
|
|
|
# "-DJPEGXL_ENABLE_VIEWERS=ON"
|
2024-04-22 11:43:33 +00:00
|
|
|
]
|
|
|
|
++ lib.optionals enablePlugins [
|
2021-06-26 16:12:04 +00:00
|
|
|
# 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
|
2024-03-29 12:41:25 +00:00
|
|
|
"-DJPEGXL_ENABLE_PLUGINS=ON"
|
2022-06-25 19:00:39 +00:00
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isStatic [
|
2022-12-01 16:15:17 +00:00
|
|
|
"-DJPEGXL_STATIC=ON"
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isAarch32 [
|
|
|
|
"-DJPEGXL_FORCE_NEON=ON"
|
2021-06-26 16:12:04 +00:00
|
|
|
];
|
|
|
|
|
2024-09-21 18:09:13 +00:00
|
|
|
# the second substitution fix regex for a2x script
|
|
|
|
# https://github.com/libjxl/libjxl/pull/3842
|
2024-03-29 12:41:25 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace plugins/gdk-pixbuf/jxl.thumbnailer \
|
|
|
|
--replace '/usr/bin/gdk-pixbuf-thumbnailer' "$out/libexec/gdk-pixbuf-thumbnailer-jxl"
|
2024-09-21 18:09:13 +00:00
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace 'sh$' 'sh( -e$|$)'
|
2024-03-29 12:41:25 +00:00
|
|
|
'';
|
|
|
|
|
2024-04-22 11:43:33 +00:00
|
|
|
postInstall =
|
|
|
|
lib.optionalString enablePlugins ''
|
2024-03-29 12:41:25 +00:00
|
|
|
GDK_PIXBUF_MODULEDIR="$out/${gdk-pixbuf.moduleDir}" \
|
|
|
|
GDK_PIXBUF_MODULE_FILE="$out/${loadersPath}" \
|
|
|
|
gdk-pixbuf-query-loaders --update-cache
|
2024-09-29 00:18:59 +00:00
|
|
|
''
|
|
|
|
# Cross-compiled gdk-pixbuf doesn't support thumbnailers
|
|
|
|
+ lib.optionalString (enablePlugins && stdenv.hostPlatform == stdenv.buildPlatform) ''
|
2024-03-29 12:41:25 +00:00
|
|
|
mkdir -p "$out/bin"
|
|
|
|
makeWrapper ${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer "$out/libexec/gdk-pixbuf-thumbnailer-jxl" \
|
|
|
|
--set GDK_PIXBUF_MODULE_FILE "$out/${loadersPath}"
|
|
|
|
'';
|
|
|
|
|
2022-12-01 16:15:17 +00:00
|
|
|
CXXFLAGS = lib.optionalString stdenv.hostPlatform.isAarch32 "-mfp16-format=ieee";
|
2022-01-09 01:59:14 +00:00
|
|
|
|
2022-12-16 13:27:29 +00:00
|
|
|
# FIXME x86_64-darwin:
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/204030#issuecomment-1352768690
|
|
|
|
doCheck = with stdenv; !(hostPlatform.isi686 || isDarwin && isx86_64);
|
2021-06-26 16:12:04 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/libjxl/libjxl";
|
|
|
|
description = "JPEG XL image format reference implementation";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ nh2 ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|