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