2021-06-26 16:12:04 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub
|
2021-12-05 23:00:05 +00:00
|
|
|
, fetchpatch
|
2021-06-26 16:12:04 +00:00
|
|
|
, 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
|
|
|
|
, openexr
|
|
|
|
, pkg-config
|
|
|
|
, zlib
|
2022-06-05 04:51:44 +00:00
|
|
|
, buildDocs ? true
|
|
|
|
, asciidoc
|
|
|
|
, graphviz
|
|
|
|
, doxygen
|
|
|
|
, python3
|
2021-06-26 16:12:04 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libjxl";
|
2021-11-03 09:21:59 +00:00
|
|
|
version = "0.6.1";
|
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}";
|
2021-11-03 09:21:59 +00:00
|
|
|
sha256 = "sha256-fTK5hyU9PZ6nigMsfzVugwviihgAXfEcLF+l+n5h+54=";
|
2021-06-26 16:12:04 +00:00
|
|
|
# There are various submodules in `third_party/`.
|
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2021-12-05 23:00:05 +00:00
|
|
|
patches = [
|
|
|
|
# present in master, remove after 0.7?
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-link-lld-macho.patch";
|
|
|
|
url = "https://github.com/libjxl/libjxl/commit/88fe3fff3dc70c72405f57c69feffd9823930034.patch";
|
|
|
|
sha256 = "1419fyiq4srpj72cynwyvqy8ldi7vn9asvkp5fsbmiqkyhb15jpk";
|
|
|
|
})
|
|
|
|
|
2021-12-12 16:16:08 +00:00
|
|
|
# "robust statistics" have been removed in upstream mainline as they are
|
|
|
|
# conidered to cause "interoperability problems". sure enough the tests
|
|
|
|
# fail with precision issues on aarch64.
|
2022-01-09 01:59:14 +00:00
|
|
|
(fetchpatch {
|
|
|
|
name = "remove-robust-and-descriptive-statistics.patch";
|
|
|
|
url = "https://github.com/libjxl/libjxl/commit/204f87a5e4d684544b13900109abf040dc0b402b.patch";
|
|
|
|
sha256 = "sha256-DoAaYWLmQ+R9GZbHMTYGe0gBL9ZesgtB+2WhmbARna8=";
|
|
|
|
})
|
2022-06-28 18:15:01 +00:00
|
|
|
|
|
|
|
# fix build with asciidoc wrapped in shell script
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/libjxl/libjxl/commit/b8ec58c58c6281987f42ebec892f513824c0cc0e.patch";
|
|
|
|
hash = "sha256-g8U+YVhLfgSHJ+PWJgvVOI66+FElJSC8IgSRodNnsMw=";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/libjxl/libjxl/commit/ca8e276aacf63a752346a6a44ba673b0af993237.patch";
|
|
|
|
excludes = [ "AUTHORS" ];
|
|
|
|
hash = "sha256-9VXy1LdJ0JhYbCGPNMySpnGLBxUrr8BYzE+oU3LnUGw=";
|
|
|
|
})
|
2022-01-09 01:59:14 +00:00
|
|
|
];
|
2021-09-05 21:13:54 +00:00
|
|
|
|
2021-06-26 16:12:04 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
gtest
|
|
|
|
pkg-config
|
2022-06-05 04:51:44 +00:00
|
|
|
] ++ lib.optionals buildDocs [
|
|
|
|
asciidoc
|
|
|
|
graphviz
|
|
|
|
doxygen
|
|
|
|
python3
|
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 = [
|
|
|
|
giflib
|
|
|
|
gperftools # provides `libtcmalloc`
|
|
|
|
libjpeg
|
|
|
|
libpng
|
|
|
|
libwebp
|
|
|
|
openexr
|
|
|
|
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"
|
|
|
|
|
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"
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
# 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-01-09 01:59:14 +00:00
|
|
|
LDFLAGS = lib.optionalString stdenv.hostPlatform.isRiscV "-latomic";
|
|
|
|
|
2022-04-04 20:58:13 +00:00
|
|
|
doCheck = !stdenv.hostPlatform.isi686;
|
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;
|
|
|
|
};
|
|
|
|
}
|