<commit_before>{ lib
, stdenv
, buildPackages
, gobject-introspection-unwrapped
, targetPackages
}:

# to build, run
# `nix build ".#pkgsCross.aarch64-multiplatform.buildPackages.gobject-introspection"`
gobject-introspection-unwrapped.overrideAttrs (_previousAttrs: {
  pname = "gobject-introspection-wrapped";
  postFixup = ''
    mv $dev/bin/g-ir-compiler $dev/bin/.g-ir-compiler-wrapped
    mv $dev/bin/g-ir-scanner $dev/bin/.g-ir-scanner-wrapped

    (
      export bash="${buildPackages.bash}/bin/bash"
      export emulator=${lib.escapeShellArg (stdenv.targetPlatform.emulator buildPackages)}
      export buildprelink="${buildPackages.prelink}/bin/prelink-rtld"

      export targetgir="${lib.getDev targetPackages.gobject-introspection-unwrapped}"<commit_msg>gobject-introspection: fix .override when the wrapper is in use<commit_after>{ lib
, stdenv
, buildPackages
, targetPackages
, gobject-introspection-unwrapped
, ...
}@_args:

# to build, run
# 'nix build ".#pkgsCross.aarch64-multiplatform.buildPackages.gobject-introspection"'

let
  # ensure that `.override` works when gobject-introspection == gobject-introspection-wrapped
  args = builtins.removeAttrs _args [ "buildPackages" "targetPackages" "gobject-introspection-unwrapped" ];
  # passing this stdenv to `targetPackages...` breaks due to splicing not working in `.override``
  argsForTarget = builtins.removeAttrs args [ "stdenv" ];
in

(gobject-introspection-unwrapped.override args).overrideAttrs (_previousAttrs: {
  pname = "gobject-introspection-wrapped";
  postFixup = ''
    mv $dev/bin/g-ir-compiler $dev/bin/.g-ir-compiler-wrapped
    mv $dev/bin/g-ir-scanner $dev/bin/.g-ir-scanner-wrapped

    (
      export bash="${buildPackages.bash}/bin/bash"
      export emulator=${lib.escapeShellArg (stdenv.targetPlatform.emulator buildPackages)}
      export buildprelink="${buildPackages.prelink}/bin/prelink-rtld"

      export targetgir="${lib.getDev (targetPackages.gobject-introspection-unwrapped.override argsForTarget)}"
{'fraction_non_alphanumeric': 0.13023952095808383, 'fraction_numerical': 0.001996007984031936, 'mean_word_length': 4.6798866855524075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1216289', 'n_tokens_mistral': 696, 'n_tokens_neox': 682, 'n_words': 110}