nixpkgs/pkgs/by-name/we/webp-pixbuf-loader/package.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

76 lines
2.1 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
meson,
ninja,
pkg-config,
makeWrapper,
gdk-pixbuf,
libwebp,
}:
let
inherit (gdk-pixbuf) moduleDir;
loadersPath = "${gdk-pixbuf.binaryDir}/webp-loaders.cache";
in
stdenv.mkDerivation rec {
pname = "webp-pixbuf-loader";
version = "0.2.6";
src = fetchFromGitHub {
owner = "aruiz";
repo = "webp-pixbuf-loader";
rev = version;
sha256 = "sha256-2GDH5+YCwb2mPdMfEscmWDOzdGnWRcppE+4rcDCZog4=";
};
nativeBuildInputs = [
gdk-pixbuf.dev
meson
ninja
pkg-config
makeWrapper
];
buildInputs = [
gdk-pixbuf
libwebp
];
mesonFlags = [
"-Dgdk_pixbuf_moduledir=${placeholder "out"}/${moduleDir}"
];
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/libexec/gdk-pixbuf-thumbnailer-webp"
'';
postInstall =
''
GDK_PIXBUF_MODULE_FILE="$out/${loadersPath}" \
GDK_PIXBUF_MODULEDIR="$out/${moduleDir}" \
gdk-pixbuf-query-loaders --update-cache
# gdk-pixbuf disables the thumbnailer in cross-builds (https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/commit/fc37708313a5fc52083cf10c9326f3509d67701f)
# and therefore makeWrapper will fail because 'gdk-pixbuf-thumbnailer' the executable does not exist.
''
+ lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
# 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/libexec/gdk-pixbuf-thumbnailer-webp" \
--set GDK_PIXBUF_MODULE_FILE "$out/${loadersPath}"
'';
meta = with lib; {
description = "WebP GDK Pixbuf Loader library";
homepage = "https://github.com/aruiz/webp-pixbuf-loader";
license = licenses.lgpl2Plus;
platforms = platforms.unix;
maintainers = teams.gnome.members ++ [ maintainers.cwyc ];
};
}