lol

libavif: build gdk-pixbuf loader and thumbnailer

https://github.com/AOMediaCodec/libavif/pull/182
https://github.com/AOMediaCodec/libavif/pull/977

Mostly mirrors webp-pixbuf-loader.

Also use prefixed names for `loaders.cache` so that users can install
multiple loaders in a profile without collisions, and move
`bin/webp-thumbnailer` to `libexec/gdk-pixbuf-thumbnailer-webp` (and
similarly for avif).

authored by

Maciej Krüger and committed by
Naïm Favier
a38770bd 4b7ad2c7

+34 -8
+3 -2
pkgs/development/libraries/gdk-pixbuf/default.nix
··· 143 143 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 144 144 }; 145 145 146 - # gdk_pixbuf_moduledir variable from gdk-pixbuf-2.0.pc 147 - moduleDir = "lib/gdk-pixbuf-2.0/2.10.0/loaders"; 146 + # gdk_pixbuf_binarydir and gdk_pixbuf_moduledir variables from gdk-pixbuf-2.0.pc 147 + binaryDir = "lib/gdk-pixbuf-2.0/2.10.0"; 148 + moduleDir = "${finalAttrs.passthru.binaryDir}/loaders"; 148 149 }; 149 150 150 151 meta = with lib; {
+28
pkgs/development/libraries/libavif/default.nix
··· 8 8 , libjpeg 9 9 , dav1d 10 10 , libyuv 11 + , gdk-pixbuf 12 + , makeWrapper 11 13 }: 14 + 15 + let 16 + gdkPixbufModuleDir = "${placeholder "out"}/${gdk-pixbuf.moduleDir}"; 17 + gdkPixbufModuleFile = "${placeholder "out"}/${gdk-pixbuf.binaryDir}/avif-loaders.cache"; 18 + in 12 19 13 20 stdenv.mkDerivation rec { 14 21 pname = "libavif"; ··· 29 36 "-DAVIF_CODEC_DAV1D=ON" # best decoder (fast) 30 37 "-DAVIF_CODEC_AOM_DECODE=OFF" 31 38 "-DAVIF_BUILD_APPS=ON" 39 + "-DAVIF_BUILD_GDK_PIXBUF=ON" 32 40 ]; 33 41 34 42 nativeBuildInputs = [ 35 43 cmake 36 44 pkg-config 45 + gdk-pixbuf 46 + makeWrapper 37 47 ]; 38 48 39 49 buildInputs = [ 50 + gdk-pixbuf 40 51 libaom 41 52 zlib 42 53 libpng ··· 44 55 dav1d 45 56 libyuv 46 57 ]; 58 + 59 + postPatch = '' 60 + substituteInPlace contrib/gdk-pixbuf/avif.thumbnailer.in \ 61 + --replace '@CMAKE_INSTALL_FULL_BINDIR@/gdk-pixbuf-thumbnailer' "$out/libexec/gdk-pixbuf-thumbnailer-avif" 62 + ''; 63 + 64 + env.PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = gdkPixbufModuleDir; 65 + 66 + postInstall = '' 67 + GDK_PIXBUF_MODULEDIR=${gdkPixbufModuleDir} \ 68 + GDK_PIXBUF_MODULE_FILE=${gdkPixbufModuleFile} \ 69 + gdk-pixbuf-query-loaders --update-cache 70 + 71 + mkdir -p "$out/bin" 72 + makeWrapper ${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer "$out/libexec/gdk-pixbuf-thumbnailer-avif" \ 73 + --set GDK_PIXBUF_MODULE_FILE ${gdkPixbufModuleFile} 74 + ''; 47 75 48 76 meta = with lib; { 49 77 description = "C implementation of the AV1 Image File Format";
+3 -6
pkgs/development/libraries/webp-pixbuf-loader/default.nix
··· 11 11 12 12 let 13 13 inherit (gdk-pixbuf) moduleDir; 14 - 15 - # turning lib/gdk-pixbuf-#.#/#.#.#/loaders into lib/gdk-pixbuf-#.#/#.#.#/loaders.cache 16 - # removeSuffix is just in case moduleDir gets a trailing slash 17 - loadersPath = (lib.strings.removeSuffix "/" gdk-pixbuf.moduleDir) + ".cache"; 14 + loadersPath = "${gdk-pixbuf.binaryDir}/webp-loaders.cache"; 18 15 in 19 16 stdenv.mkDerivation rec { 20 17 pname = "webp-pixbuf-loader"; ··· 47 44 postPatch = '' 48 45 # It looks for gdk-pixbuf-thumbnailer in this package's bin rather than the gdk-pixbuf bin. We need to patch that. 49 46 substituteInPlace webp-pixbuf.thumbnailer.in \ 50 - --replace "@bindir@/gdk-pixbuf-thumbnailer" "$out/bin/webp-thumbnailer" 47 + --replace "@bindir@/gdk-pixbuf-thumbnailer" "$out/libexec/gdk-pixbuf-thumbnailer-webp" 51 48 ''; 52 49 53 50 postInstall = '' ··· 58 55 # It assumes gdk-pixbuf-thumbnailer can find the webp loader in the loaders.cache referenced by environment variable, breaking containment. 59 56 # So we replace it with a wrapped executable. 60 57 mkdir -p "$out/bin" 61 - makeWrapper "${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer" "$out/bin/webp-thumbnailer" \ 58 + makeWrapper "${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer" "$out/libexec/gdk-pixbuf-thumbnailer-webp" \ 62 59 --set GDK_PIXBUF_MODULE_FILE "$out/${loadersPath}" 63 60 ''; 64 61