20 , gobject-introspection-unwrapped
21 , nixStoreDir ? builtins.storeDir
24 , propagateFullGlib ? true
27 # now that gobject-introspection creates large .gir files (eg gtk3 case)
28 # it may be worth thinking about using multiple derivation outputs
29 # In that case its about 6MB which could be separated
38 # https://discourse.gnome.org/t/dealing-with-glib-and-gobject-introspection-circular-dependency/18701
39 glib' = glib.override { withIntrospection = false; };
41 stdenv.mkDerivation (finalAttrs: {
42 pname = "gobject-introspection";
45 # outputs TODO: share/gobject-introspection-1.0/tests is needed during build
46 # by pygobject3 (and maybe others), but it's only searched in $out
47 outputs = [ "out" "dev" "devdoc" "man" ];
51 url = "mirror://gnome/sources/gobject-introspection/${lib.versions.majorMinor finalAttrs.version}/gobject-introspection-${finalAttrs.version}.tar.xz";
52 hash = "sha256-D1pMGQhCS/JrxB6TYRaMNjaFCA+9uHoZbIkchAHKLwk=";
56 # Make g-ir-scanner put absolute path to GIR files it generates
57 # so that programs can just dlopen them without having to muck
58 # with LD_LIBRARY_PATH environment variable.
60 src = ./absolute_shlib_path.patch;
63 ] ++ lib.optionals x11Support [
64 # Hardcode the cairo shared library path in the Cairo gir shipped with this package.
65 # https://github.com/NixOS/nixpkgs/issues/34080
67 src = ./absolute_gir_path.patch;
68 cairoLib = "${lib.getLib cairo}/lib";
83 # Build definition checks for the Python modules needed at runtime by importing them.
84 (buildPackages.python3.withPackages pythonModules)
85 finalAttrs.setupHook # move .gir files
86 # can't use canExecute, we need prebuilt when cross
87 ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ gobject-introspection-unwrapped ];
90 (python3.withPackages pythonModules)
93 nativeCheckInputs = lib.optionals stdenv.hostPlatform.isDarwin [
97 propagatedBuildInputs = [
99 (if propagateFullGlib then glib else glib')
103 "--datadir=${placeholder "dev"}/share"
105 "-Dgtk_doc=${lib.boolToString (stdenv.hostPlatform == stdenv.buildPlatform)}"
106 ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
107 "-Dgi_cross_ldd_wrapper=${substituteAll {
108 name = "g-ir-scanner-lddwrapper";
110 src = ./wrappers/g-ir-scanner-lddwrapper.sh;
111 inherit (buildPackages) bash;
112 buildlddtree = "${buildPackages.pax-utils}/bin/lddtree";
114 "-Dgi_cross_binary_wrapper=${stdenv.hostPlatform.emulator buildPackages}"
115 # can't use canExecute, we need prebuilt when cross
116 ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
117 "-Dgi_cross_use_prebuilt_gi=true"
120 doCheck = !stdenv.hostPlatform.isAarch64;
122 # During configurePhase, two python scripts are generated and need this. See
123 # https://github.com/NixOS/nixpkgs/pull/98316#issuecomment-695785692
125 patchShebangs tools/*
128 postInstall = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
129 cp -r ${buildPackages.gobject-introspection-unwrapped.devdoc} $devdoc
130 # these are uncompiled c and header files which aren't installed when cross-compiling because
131 # code that installs them is in tests/meson.build which is only run when not cross-compiling
132 # pygobject3 needs them
133 cp -r ${buildPackages.gobject-introspection-unwrapped.dev}/share/gobject-introspection-1.0/tests $dev/share/gobject-introspection-1.0/tests
137 # Our gobject-introspection patches make the shared library paths absolute
138 # in the GIR files. When running tests, the library is not yet installed,
139 # though, so we need to replace the absolute path with a local one during build.
140 # We are using a symlink that we will delete before installation.
142 ln -s $PWD/tests/scanner/libregress-1.0${stdenv.targetPlatform.extensions.sharedLibrary} $out/lib/libregress-1.0${stdenv.targetPlatform.extensions.sharedLibrary}
146 rm $out/lib/libregress-1.0${stdenv.targetPlatform.extensions.sharedLibrary}
149 setupHook = ./setup-hook.sh;
152 updateScript = gnome.updateScript {
153 packageName = "gobject-introspection";
154 versionPolicy = "odd-unstable";
156 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
160 description = "Middleware layer between C libraries and language bindings";
161 homepage = "https://gi.readthedocs.io/";
162 maintainers = teams.gnome.members ++ (with maintainers; [ lovek323 artturin ]);
163 pkgConfigModules = [ "gobject-introspection-1.0" ];
164 platforms = platforms.unix;
165 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
166 license = with licenses; [ gpl2 lgpl2 ];
169 GObject introspection is a middleware layer between C libraries (using
170 GObject) and language bindings. The C library can be scanned at compile
171 time and generate a metadata file, in addition to the actual native C
172 library. Then at runtime, language bindings can read this metadata and
173 automatically provide bindings to call into the C library.