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).
This commit is contained in:
parent
4b7ad2c7ea
commit
a38770bd69
|
@ -143,8 +143,9 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
||||
};
|
||||
|
||||
# gdk_pixbuf_moduledir variable from gdk-pixbuf-2.0.pc
|
||||
moduleDir = "lib/gdk-pixbuf-2.0/2.10.0/loaders";
|
||||
# gdk_pixbuf_binarydir and gdk_pixbuf_moduledir variables from gdk-pixbuf-2.0.pc
|
||||
binaryDir = "lib/gdk-pixbuf-2.0/2.10.0";
|
||||
moduleDir = "${finalAttrs.passthru.binaryDir}/loaders";
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
|
|
|
@ -8,8 +8,15 @@
|
|||
, libjpeg
|
||||
, dav1d
|
||||
, libyuv
|
||||
, gdk-pixbuf
|
||||
, makeWrapper
|
||||
}:
|
||||
|
||||
let
|
||||
gdkPixbufModuleDir = "${placeholder "out"}/${gdk-pixbuf.moduleDir}";
|
||||
gdkPixbufModuleFile = "${placeholder "out"}/${gdk-pixbuf.binaryDir}/avif-loaders.cache";
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "libavif";
|
||||
version = "0.11.1";
|
||||
|
@ -29,14 +36,18 @@ stdenv.mkDerivation rec {
|
|||
"-DAVIF_CODEC_DAV1D=ON" # best decoder (fast)
|
||||
"-DAVIF_CODEC_AOM_DECODE=OFF"
|
||||
"-DAVIF_BUILD_APPS=ON"
|
||||
"-DAVIF_BUILD_GDK_PIXBUF=ON"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
gdk-pixbuf
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
gdk-pixbuf
|
||||
libaom
|
||||
zlib
|
||||
libpng
|
||||
|
@ -45,6 +56,23 @@ stdenv.mkDerivation rec {
|
|||
libyuv
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace contrib/gdk-pixbuf/avif.thumbnailer.in \
|
||||
--replace '@CMAKE_INSTALL_FULL_BINDIR@/gdk-pixbuf-thumbnailer' "$out/libexec/gdk-pixbuf-thumbnailer-avif"
|
||||
'';
|
||||
|
||||
env.PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = gdkPixbufModuleDir;
|
||||
|
||||
postInstall = ''
|
||||
GDK_PIXBUF_MODULEDIR=${gdkPixbufModuleDir} \
|
||||
GDK_PIXBUF_MODULE_FILE=${gdkPixbufModuleFile} \
|
||||
gdk-pixbuf-query-loaders --update-cache
|
||||
|
||||
mkdir -p "$out/bin"
|
||||
makeWrapper ${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer "$out/libexec/gdk-pixbuf-thumbnailer-avif" \
|
||||
--set GDK_PIXBUF_MODULE_FILE ${gdkPixbufModuleFile}
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "C implementation of the AV1 Image File Format";
|
||||
longDescription = ''
|
||||
|
|
|
@ -11,10 +11,7 @@
|
|||
|
||||
let
|
||||
inherit (gdk-pixbuf) moduleDir;
|
||||
|
||||
# turning lib/gdk-pixbuf-#.#/#.#.#/loaders into lib/gdk-pixbuf-#.#/#.#.#/loaders.cache
|
||||
# removeSuffix is just in case moduleDir gets a trailing slash
|
||||
loadersPath = (lib.strings.removeSuffix "/" gdk-pixbuf.moduleDir) + ".cache";
|
||||
loadersPath = "${gdk-pixbuf.binaryDir}/webp-loaders.cache";
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "webp-pixbuf-loader";
|
||||
|
@ -47,7 +44,7 @@ stdenv.mkDerivation rec {
|
|||
postPatch = ''
|
||||
# It looks for gdk-pixbuf-thumbnailer in this package's bin rather than the gdk-pixbuf bin. We need to patch that.
|
||||
substituteInPlace webp-pixbuf.thumbnailer.in \
|
||||
--replace "@bindir@/gdk-pixbuf-thumbnailer" "$out/bin/webp-thumbnailer"
|
||||
--replace "@bindir@/gdk-pixbuf-thumbnailer" "$out/libexec/gdk-pixbuf-thumbnailer-webp"
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
|
@ -58,7 +55,7 @@ stdenv.mkDerivation rec {
|
|||
# It assumes gdk-pixbuf-thumbnailer can find the webp loader in the loaders.cache referenced by environment variable, breaking containment.
|
||||
# So we replace it with a wrapped executable.
|
||||
mkdir -p "$out/bin"
|
||||
makeWrapper "${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer" "$out/bin/webp-thumbnailer" \
|
||||
makeWrapper "${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer" "$out/libexec/gdk-pixbuf-thumbnailer-webp" \
|
||||
--set GDK_PIXBUF_MODULE_FILE "$out/${loadersPath}"
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue