about summary refs log tree commit diff
path: root/pkgs/development/libraries/gobject-introspection
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2022-07-14 02:10:16 +0300
committerArtturin <Artturin@artturin.com>2022-07-14 07:14:41 +0300
commite8ecd00e4699472f861113e525536b4f16f68689 (patch)
tree16948af1c7fdb55cc0ef221e617525fa77530402 /pkgs/development/libraries/gobject-introspection
parent1570838769fad637e3cf26a56ab6ff14d23c4b95 (diff)
gobject-introspection: override pkg-config variables in a setup hook
instead of substituteInPlace

fixes gtk2 because it needs g_ir_scanner to be a path
Diffstat (limited to 'pkgs/development/libraries/gobject-introspection')
-rw-r--r--pkgs/development/libraries/gobject-introspection/default.nix10
-rw-r--r--pkgs/development/libraries/gobject-introspection/wrapper.nix17
2 files changed, 17 insertions, 10 deletions
diff --git a/pkgs/development/libraries/gobject-introspection/default.nix b/pkgs/development/libraries/gobject-introspection/default.nix
index bfcb9a4401448..896db9c467213 100644
--- a/pkgs/development/libraries/gobject-introspection/default.nix
+++ b/pkgs/development/libraries/gobject-introspection/default.nix
@@ -124,16 +124,6 @@ stdenv.mkDerivation (finalAttrs: {
     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 = {
diff --git a/pkgs/development/libraries/gobject-introspection/wrapper.nix b/pkgs/development/libraries/gobject-introspection/wrapper.nix
index 46000073205cc..87ed44f9db1e3 100644
--- a/pkgs/development/libraries/gobject-introspection/wrapper.nix
+++ b/pkgs/development/libraries/gobject-introspection/wrapper.nix
@@ -28,5 +28,22 @@ gobject-introspection-unwrapped.overrideAttrs (previousAttrs: {
       chmod +x "$dev/bin/g-ir-compiler"
       chmod +x "$dev/bin/g-ir-scanner"
     )
+  ''
+  # 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
+  # override the variable to use the absolute path to g_ir_X in PATH which can be run
+  + ''
+    cat >> $dev/nix-support/setup-hook <<-'EOF'
+      override-pkg-config-gir-variables() {
+        PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_SCANNER="$(type -p g-ir-scanner)"
+        PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_COMPILER="$(type -p g-ir-compiler)"
+        PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_GENERATE="$(type -p g-ir-generate)"
+        export PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_SCANNER
+        export PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_COMPILER
+        export PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_GENERATE
+      }
+
+      preConfigureHooks+=(override-pkg-config-gir-variables)
+    EOF
   '';
 })