libjxl, jpegli: Fix file conflicts when installed together. Fixes #533459

Done by moving the benchmarks and library files to separate outputs
so one can reference only `.bin` in `systemPackages`,
avoiding the overlapping names:

    bin/benchmark_xl
    lib/libjxl_cms.so
    lib/libjxl_threads.so
    lib/libjxl_extras_codec.a

For jpegli, a `dev` output also needed to be added to remove a cyclic
reference (from `out` to `bin`):
With a `bin` output newly present, the nixpkgs `multiple-outputs` hook
emits `nix-support/propagated-build-inputs` (which lists the `bin` output)
as development metadata. Without a `dev` output this lands in `out`,
creating an `out -> bin -> out` reference cycle (`bin` links the runtime
libs in `out`).
Example of what was in `bin`'s `nix-support/propagated-build-inputs`:

    /nix/store/99f61f783cd29k1gmr7hrxjnb4v584jn-jpegli-0-unstable-2026-04-30-bin /nix/store/320lmb4fnd2x5alv9hlpdlgz73aj8f26-jpegli-0-unstable-2026-04-30

Creating `dev` moves `nix-support` there, breaking the cycle
and matching the `libjxl` output layout.

Assisted-By: Claude Opus 4.8 in Zoo Code
This commit is contained in:
Niklas Hambüchen 2026-06-20 00:42:53 +00:00
commit ed76de3e2a
2 changed files with 27 additions and 12 deletions

View file

@ -31,7 +31,10 @@ stdenv.mkDerivation {
outputs = [
"out"
"bin"
"dev"
"man"
"benchmark"
];
strictDeps = true;
@ -70,6 +73,12 @@ stdenv.mkDerivation {
(lib.cmakeFeature "CMAKE_POLICY_VERSION_MINIMUM" "3.5")
];
# Move `benchmark_xl` into a separate output to avoid a file collision
# with the `benchmark_xl` binary provided by `libjxl`.
postInstall = ''
moveToOutput "bin/benchmark_xl" "$benchmark"
'';
doCheck = true;
passthru = {

View file

@ -35,7 +35,9 @@ stdenv.mkDerivation rec {
outputs = [
"out"
"bin"
"dev"
"benchmark"
];
src = fetchFromGitHub {
@ -150,18 +152,22 @@ stdenv.mkDerivation rec {
--replace 'sh$' 'sh( -e$|$)'
'';
postInstall =
lib.optionalString enablePlugins ''
GDK_PIXBUF_MODULEDIR="$out/${gdk-pixbuf.moduleDir}" \
GDK_PIXBUF_MODULE_FILE="$out/${loadersPath}" \
gdk-pixbuf-query-loaders --update-cache
''
# Cross-compiled gdk-pixbuf doesn't support thumbnailers
+ lib.optionalString (enablePlugins && stdenv.hostPlatform == stdenv.buildPlatform) ''
mkdir -p "$out/bin"
makeWrapper ${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer "$out/libexec/gdk-pixbuf-thumbnailer-jxl" \
--set GDK_PIXBUF_MODULE_FILE "$out/${loadersPath}"
'';
# Move `benchmark_xl` into a separate output to avoid a file collision
# with the `benchmark_xl` binary provided by `jpegli`.
postInstall = ''
moveToOutput "bin/benchmark_xl" "$benchmark"
''
+ lib.optionalString enablePlugins ''
GDK_PIXBUF_MODULEDIR="$out/${gdk-pixbuf.moduleDir}" \
GDK_PIXBUF_MODULE_FILE="$out/${loadersPath}" \
gdk-pixbuf-query-loaders --update-cache
''
# Cross-compiled gdk-pixbuf doesn't support thumbnailers
+ lib.optionalString (enablePlugins && stdenv.hostPlatform == stdenv.buildPlatform) ''
mkdir -p "$out/bin"
makeWrapper ${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer "$out/libexec/gdk-pixbuf-thumbnailer-jxl" \
--set GDK_PIXBUF_MODULE_FILE "$out/${loadersPath}"
'';
env = lib.optionalAttrs stdenv.hostPlatform.isAarch32 {
CXXFLAGS = "-mfp16-format=ieee";