summary refs log tree commit diff
path: root/pkgs/development/libraries/gobject-introspection/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/gobject-introspection/default.nix')
-rw-r--r--pkgs/development/libraries/gobject-introspection/default.nix24
1 files changed, 19 insertions, 5 deletions
diff --git a/pkgs/development/libraries/gobject-introspection/default.nix b/pkgs/development/libraries/gobject-introspection/default.nix
index 82be84e1f1d..bfcb9a44014 100644
--- a/pkgs/development/libraries/gobject-introspection/default.nix
+++ b/pkgs/development/libraries/gobject-introspection/default.nix
@@ -27,7 +27,7 @@
 # it may be worth thinking about using multiple derivation outputs
 # In that case its about 6MB which could be separated
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation (finalAttrs: {
   pname = "gobject-introspection";
   version = "1.72.0";
 
@@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
   outputBin = "dev";
 
   src = fetchurl {
-    url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    url = "mirror://gnome/sources/gobject-introspection/${lib.versions.majorMinor finalAttrs.version}/gobject-introspection-${finalAttrs.version}.tar.xz";
     sha256 = "Av6OWQhh2I+DBg3TnNpcyqYLLaHSHQ+VSZMBsYa+qrw=";
   };
 
@@ -68,7 +68,7 @@ stdenv.mkDerivation rec {
     docbook-xsl-nons
     docbook_xml_dtd_45
     python3
-    setupHook # move .gir files
+    finalAttrs.setupHook # move .gir files
   ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ gobject-introspection-unwrapped ];
 
   buildInputs = [
@@ -105,6 +105,10 @@ stdenv.mkDerivation rec {
 
   postInstall = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
     cp -r ${buildPackages.gobject-introspection-unwrapped.devdoc} $devdoc
+    # these are uncompiled c and header files which aren't installed when cross-compiling because
+    # code that installs them is in tests/meson.build which is only run when not cross-compiling
+    # pygobject3 needs them
+    cp -r ${buildPackages.gobject-introspection-unwrapped.dev}/share/gobject-introspection-1.0/tests $dev/share/gobject-introspection-1.0/tests
   '';
 
   preCheck = ''
@@ -120,11 +124,21 @@ stdenv.mkDerivation rec {
     rm $out/lib/libregress-1.0${stdenv.targetPlatform.extensions.sharedLibrary}
   '';
 
+  # when cross-compiling and using the wrapper then when a package looks up the g_ir_X
+  # variable with pkg-config they'll get the host version which can't be run
+  # switch the variables to use g_ir_X from path instead of an absolute path
+  postFixup = lib.optionalString (!lib.hasSuffix "wrapped" finalAttrs.pname) ''
+    find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do
+        substituteInPlace "$pc" \
+          --replace '=''${bindir}/g-ir' '=g-ir'
+    done
+  '';
+
   setupHook = ./setup-hook.sh;
 
   passthru = {
     updateScript = gnome.updateScript {
-      packageName = pname;
+      packageName = "gobject-introspection";
       versionPolicy = "odd-unstable";
     };
   };
@@ -144,4 +158,4 @@ stdenv.mkDerivation rec {
       automatically provide bindings to call into the C library.
     '';
   };
-}
+})