Files
nixpkgs/pkgs/by-name/li/librsvg/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

229 lines
5.7 KiB
Nix

{
lib,
stdenv,
fetchurl,
pkg-config,
meson,
ninja,
glib,
gdk-pixbuf,
installShellFiles,
pango,
freetype,
cairo,
libxml2,
bzip2,
dav1d,
rustPlatform,
rustc,
cargo-c,
cargo-auditable-cargo-wrapper,
gi-docgen,
python3Packages,
gnome,
vala,
shared-mime-info,
# Requires building a cdylib.
withPixbufLoader ? !stdenv.hostPlatform.isStatic,
withIntrospection ?
lib.meta.availableOn stdenv.hostPlatform gobject-introspection
&& stdenv.hostPlatform.emulatorAvailable buildPackages,
buildPackages,
gobject-introspection,
mesonEmulatorHook,
_experimental-update-script-combinators,
common-updater-scripts,
jq,
nix,
# for passthru.tests
enlightenment,
ffmpeg,
gegl,
gimp,
imagemagick,
imlib2,
vips,
xfce,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "librsvg";
version = "2.61.1";
outputs = [
"out"
"dev"
]
++ lib.optionals withIntrospection [
"devdoc"
];
src = fetchurl {
url = "mirror://gnome/sources/librsvg/${lib.versions.majorMinor finalAttrs.version}/librsvg-${finalAttrs.version}.tar.xz";
hash = "sha256-vBu81BkSCwmNsovqVTNdneJHDU5qn27pcge0EPwVhn0=";
};
cargoDeps = rustPlatform.fetchCargoVendor {
inherit (finalAttrs) src;
name = "librsvg-deps-${finalAttrs.version}";
hash = "sha256-3DAFyY7uNB5cP8ry28v12QsFdxHtpr1nyLtzhojBq7c=";
dontConfigure = true;
};
strictDeps = true;
depsBuildBuild = [
pkg-config
];
nativeBuildInputs = [
installShellFiles
pkg-config
meson
ninja
rustc
cargo-c
cargo-auditable-cargo-wrapper
python3Packages.docutils
rustPlatform.cargoSetupHook
]
++ lib.optionals withIntrospection [
gobject-introspection
gi-docgen
vala # vala bindings require GObject introspection
]
++ lib.optionals (withIntrospection && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
mesonEmulatorHook
];
buildInputs = [
libxml2
bzip2
dav1d
pango
freetype
]
++ lib.optionals withIntrospection [
vala # for share/vala/Makefile.vapigen
];
propagatedBuildInputs = [
glib
gdk-pixbuf
cairo
];
mesonFlags = [
"-Dtriplet=${stdenv.hostPlatform.rust.rustcTarget}"
(lib.mesonEnable "introspection" withIntrospection)
(lib.mesonEnable "pixbuf-loader" withPixbufLoader)
(lib.mesonEnable "vala" withIntrospection)
(lib.mesonBool "tests" finalAttrs.finalPackage.doCheck)
];
# Probably broken MIME type detection on Darwin.
# Tests fail with imprecise rendering on i686.
doCheck = !stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isi686;
env = {
PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_QUERY_LOADERS = buildPackages.writeShellScript "gdk-pixbuf-loader-loaders-wrapped" ''
${lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (stdenv.hostPlatform.emulator buildPackages)} ${lib.getDev gdk-pixbuf}/bin/gdk-pixbuf-query-loaders
'';
};
postPatch = ''
patchShebangs \
meson/cargo_wrapper.py \
meson/makedef.py \
meson/query-rustc.py
# Fix thumbnailer path
substituteInPlace gdk-pixbuf-loader/librsvg.thumbnailer.in \
--replace-fail '@bindir@/gdk-pixbuf-thumbnailer' '${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer'
'';
preCheck = ''
# Tests complain: Fontconfig error: No writable cache directories
export HOME=$TMPDIR
# https://gitlab.gnome.org/GNOME/librsvg/-/issues/258#note_251789
export XDG_DATA_DIRS=${shared-mime-info}/share:$XDG_DATA_DIRS
'';
postInstall =
let
emulator = stdenv.hostPlatform.emulator buildPackages;
in
lib.optionalString withPixbufLoader ''
# Merge gdkpixbuf and librsvg loaders
GDK_PIXBUF=$out/${gdk-pixbuf.binaryDir}
cat ${lib.getLib gdk-pixbuf}/${gdk-pixbuf.binaryDir}/loaders.cache $GDK_PIXBUF/loaders.cache > $GDK_PIXBUF/loaders.cache.tmp
mv $GDK_PIXBUF/loaders.cache.tmp $GDK_PIXBUF/loaders.cache
''
+ lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ''
installShellCompletion --cmd rsvg-convert \
--bash <(${emulator} $out/bin/rsvg-convert --completion bash) \
--fish <(${emulator} $out/bin/rsvg-convert --completion fish) \
--zsh <(${emulator} $out/bin/rsvg-convert --completion zsh)
'';
postFixup = lib.optionalString withIntrospection ''
# Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
moveToOutput "share/doc" "$devdoc"
'';
passthru = {
updateScript =
let
updateSource = gnome.updateScript {
packageName = "librsvg";
};
updateLockfile = {
command = [
"sh"
"-c"
''
PATH=${
lib.makeBinPath [
common-updater-scripts
jq
nix
]
}
update-source-version librsvg --ignore-same-version --source-key=cargoDeps.vendorStaging > /dev/null
''
];
# Experimental feature: do not copy!
supportedFeatures = [ "silent" ];
};
in
_experimental-update-script-combinators.sequence [
updateSource
updateLockfile
];
tests = {
inherit
gegl
gimp
imagemagick
imlib2
vips
;
inherit (enlightenment) efl;
inherit (xfce) xfwm4;
ffmpeg = ffmpeg.override { withSvg = true; };
};
};
meta = with lib; {
description = "Small library to render SVG images to Cairo surfaces";
homepage = "https://gitlab.gnome.org/GNOME/librsvg";
license = licenses.lgpl2Plus;
teams = [ teams.gnome ];
mainProgram = "rsvg-convert";
platforms = platforms.unix;
};
})