From 227ee089f6f50f0e021155874031d345590df582 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 10 Feb 2025 11:20:17 +0100 Subject: [PATCH] librsvg: fix cross MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some things have changed with the switch to Meson: • The pixbuf stuff is only generated when build = host, even if an emulator would be available. • -Dtriplet needs to be passed when cross compiling. • This version of librsvg does not allow gobject-introspection to be enabled when cross compiling. Backport the fix for that. Fixes: c202e21f6445 ("librsvg: 2.58.3 → 2.59.2") --- .../development/libraries/librsvg/default.nix | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/librsvg/default.nix b/pkgs/development/libraries/librsvg/default.nix index 4f6e93674408..d78cac09cb41 100644 --- a/pkgs/development/libraries/librsvg/default.nix +++ b/pkgs/development/libraries/librsvg/default.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchurl, + fetchpatch, pkg-config, meson, ninja, @@ -31,6 +32,7 @@ && stdenv.hostPlatform.emulatorAvailable buildPackages, buildPackages, gobject-introspection, + mesonEmulatorHook, _experimental-update-script-combinators, common-updater-scripts, jq, @@ -65,6 +67,14 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-7NKT+wzDOMFwFxu8e8++pnJdBByV8xOF3JNUCZM+RZc="; }; + patches = [ + (fetchpatch { + name = "cross-introspection.patch"; + url = "https://gitlab.gnome.org/GNOME/librsvg/-/commit/84f24b1f5767f807f8d0442bbf3f149a0defcf78.patch"; + hash = "sha256-FRyAYCCP3eu7YDUS6g7sKCdbq2nU8yQdbdVaQwLrlhE="; + }) + ]; + cargoDeps = rustPlatform.fetchCargoVendor { inherit (finalAttrs) src; name = "librsvg-deps-${finalAttrs.version}"; @@ -95,6 +105,9 @@ stdenv.mkDerivation (finalAttrs: { gobject-introspection gi-docgen vala # vala bindings require GObject introspection + ] + ++ lib.optionals (withIntrospection && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ + mesonEmulatorHook ]; buildInputs = @@ -119,6 +132,7 @@ stdenv.mkDerivation (finalAttrs: { ]; mesonFlags = [ + "-Dtriplet=${stdenv.hostPlatform.rust.rustcTarget}" (lib.mesonEnable "introspection" withIntrospection) (lib.mesonEnable "vala" withIntrospection) (lib.mesonBool "tests" finalAttrs.finalPackage.doCheck) @@ -156,17 +170,18 @@ stdenv.mkDerivation (finalAttrs: { export XDG_DATA_DIRS=${shared-mime-info}/share:$XDG_DATA_DIRS ''; - # Not generated when cross compiling. postInstall = let emulator = stdenv.hostPlatform.emulator buildPackages; in - lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) '' + # Not generated when cross compiling. + lib.optionalString (lib.systems.equals stdenv.buildPlatform stdenv.hostPlatform) '' # 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) \