2021-06-26 18:12:04 +02:00
|
|
|
{ stdenv, lib, fetchFromGitHub
|
2023-03-21 03:53:42 +01:00
|
|
|
, fetchpatch
|
2021-06-26 18:12:04 +02:00
|
|
|
, brotli
|
|
|
|
, cmake
|
|
|
|
, giflib
|
|
|
|
, gperftools
|
|
|
|
, gtest
|
2022-01-09 02:59:14 +01:00
|
|
|
, libhwy
|
2021-06-26 18:12:04 +02:00
|
|
|
, libjpeg
|
|
|
|
, libpng
|
|
|
|
, libwebp
|
2024-01-11 12:33:48 +01:00
|
|
|
, openexr_3
|
2021-06-26 18:12:04 +02:00
|
|
|
, pkg-config
|
|
|
|
, zlib
|
2022-06-05 06:51:44 +02:00
|
|
|
, buildDocs ? true
|
|
|
|
, asciidoc
|
|
|
|
, graphviz
|
|
|
|
, doxygen
|
|
|
|
, python3
|
2021-06-26 18:12:04 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libjxl";
|
2023-06-15 13:38:06 +02:00
|
|
|
version = "0.8.2";
|
2021-06-26 18:12:04 +02:00
|
|
|
|
2022-08-03 02:02:21 +02:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2021-06-26 18:12:04 +02:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "libjxl";
|
|
|
|
repo = "libjxl";
|
2021-09-05 18:04:18 +02:00
|
|
|
rev = "v${version}";
|
2023-06-15 13:38:06 +02:00
|
|
|
hash = "sha256-I3PGgh0XqRkCFz7lUZ3Q4eU0+0GwaQcVb6t4Pru1kKo=";
|
2021-06-26 18:12:04 +02:00
|
|
|
# There are various submodules in `third_party/`.
|
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2023-03-21 03:53:42 +01:00
|
|
|
patches = [
|
|
|
|
# Add missing <atomic> content to fix gcc compilation for RISCV architecture
|
|
|
|
# https://github.com/libjxl/libjxl/pull/2211
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/libjxl/libjxl/commit/22d12d74e7bc56b09cfb1973aa89ec8d714fa3fc.patch";
|
|
|
|
hash = "sha256-X4fbYTMS+kHfZRbeGzSdBW5jQKw8UN44FEyFRUtw0qo=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-06-26 18:12:04 +02:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
gtest
|
|
|
|
pkg-config
|
2022-06-05 06:51:44 +02:00
|
|
|
] ++ lib.optionals buildDocs [
|
|
|
|
asciidoc
|
|
|
|
doxygen
|
|
|
|
python3
|
2021-06-26 18:12:04 +02:00
|
|
|
];
|
|
|
|
|
2022-06-25 21:00:39 +02:00
|
|
|
depsBuildBuild = lib.optionals buildDocs [
|
|
|
|
graphviz
|
|
|
|
];
|
|
|
|
|
2021-06-26 18:12:04 +02: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 = [
|
|
|
|
giflib
|
|
|
|
gperftools # provides `libtcmalloc`
|
|
|
|
libjpeg
|
|
|
|
libpng
|
|
|
|
libwebp
|
2024-01-11 12:33:48 +01:00
|
|
|
openexr_3
|
2021-06-26 18:12:04 +02:00
|
|
|
zlib
|
|
|
|
];
|
|
|
|
|
2022-06-12 09:28:52 +02:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
brotli
|
|
|
|
libhwy
|
|
|
|
];
|
|
|
|
|
2021-06-26 18:12:04 +02: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"
|
|
|
|
|
2022-01-09 02:59:14 +01:00
|
|
|
# Use our version of highway, though it is still statically linked in
|
|
|
|
"-DJPEGXL_FORCE_SYSTEM_HWY=ON"
|
|
|
|
|
2023-03-01 07:24:14 +01:00
|
|
|
# Use our version of gtest
|
|
|
|
"-DJPEGXL_FORCE_SYSTEM_GTEST=ON"
|
|
|
|
|
2021-06-26 18:12:04 +02:00
|
|
|
# TODO: Update this package to enable this (overridably via an option):
|
|
|
|
# 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"
|
2022-06-25 21:00:39 +02:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isStatic [
|
2022-12-01 17:15:17 +01:00
|
|
|
"-DJPEGXL_STATIC=ON"
|
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isAarch32 [
|
|
|
|
"-DJPEGXL_FORCE_NEON=ON"
|
2021-06-26 18:12:04 +02:00
|
|
|
];
|
|
|
|
|
2022-12-01 17:15:17 +01:00
|
|
|
CXXFLAGS = lib.optionalString stdenv.hostPlatform.isAarch32 "-mfp16-format=ieee";
|
2022-01-09 02:59:14 +01:00
|
|
|
|
2022-12-16 14:27:29 +01: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 18:12:04 +02: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;
|
|
|
|
};
|
|
|
|
}
|