fork
Configure Feed
Select the types of activity you want to include in your feed.
lol
fork
Configure Feed
Select the types of activity you want to include in your feed.
1{
2 stdenv,
3 lib,
4 fetchurl,
5 fetchpatch,
6 glib,
7 flex,
8 bison,
9 meson,
10 ninja,
11 gtk-doc,
12 docbook-xsl-nons,
13 docbook_xml_dtd_45,
14 pkg-config,
15 libffi,
16 python3,
17 cctools,
18 cairo,
19 gnome,
20 replaceVars,
21 replaceVarsWith,
22 buildPackages,
23 gobject-introspection-unwrapped,
24 nixStoreDir ? builtins.storeDir,
25 x11Support ? true,
26 testers,
27 propagateFullGlib ? true,
28}:
29
30# now that gobject-introspection creates large .gir files (eg gtk3 case)
31# it may be worth thinking about using multiple derivation outputs
32# In that case its about 6MB which could be separated
33
34let
35 pythonModules = pp: [
36 pp.mako
37 pp.markdown
38 pp.setuptools
39 ];
40
41 # https://discourse.gnome.org/t/dealing-with-glib-and-gobject-introspection-circular-dependency/18701
42 glib' = glib.override { withIntrospection = false; };
43in
44stdenv.mkDerivation (finalAttrs: {
45 pname = "gobject-introspection";
46 version = "1.84.0";
47
48 # outputs TODO: share/gobject-introspection-1.0/tests is needed during build
49 # by pygobject3 (and maybe others), but it's only searched in $out
50 outputs = [
51 "out"
52 "dev"
53 "devdoc"
54 "man"
55 ];
56 outputBin = "dev";
57
58 src = fetchurl {
59 url = "mirror://gnome/sources/gobject-introspection/${lib.versions.majorMinor finalAttrs.version}/gobject-introspection-${finalAttrs.version}.tar.xz";
60 hash = "sha256-lFtX2n7CYuXCZrieCR0UvoAMxCQnfYKgKHK315SoR3k=";
61 };
62
63 patches = [
64 # Make g-ir-scanner put absolute path to GIR files it generates
65 # so that programs can just dlopen them without having to muck
66 # with LD_LIBRARY_PATH environment variable.
67 (replaceVars ./absolute_shlib_path.patch {
68 inherit nixStoreDir;
69 })
70
71 # Fix getter heuristics regression
72 # https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/529
73 ./0001-scanner-Prefer-some-getters-over-others.patch
74 ]
75 ++ lib.optionals x11Support [
76 # Hardcode the cairo shared library path in the Cairo gir shipped with this package.
77 # https://github.com/NixOS/nixpkgs/issues/34080
78 (replaceVars ./absolute_gir_path.patch {
79 cairoLib = "${lib.getLib cairo}/lib";
80 # original source code in patch's context
81 CAIRO_GIR_PACKAGE = null;
82 CAIRO_SHARED_LIBRARY = null;
83 })
84 ];
85
86 strictDeps = true;
87
88 nativeBuildInputs = [
89 meson
90 ninja
91 pkg-config
92 flex
93 bison
94 gtk-doc
95 docbook-xsl-nons
96 docbook_xml_dtd_45
97 # Build definition checks for the Python modules needed at runtime by importing them.
98 (buildPackages.python3.withPackages pythonModules)
99 finalAttrs.setupHook # move .gir files
100 # can't use canExecute, we need prebuilt when cross
101 ]
102 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ gobject-introspection-unwrapped ];
103
104 buildInputs = [
105 (python3.withPackages pythonModules)
106 ];
107
108 nativeCheckInputs = lib.optionals stdenv.hostPlatform.isDarwin [
109 cctools # for otool
110 ];
111
112 propagatedBuildInputs = [
113 libffi
114 (if propagateFullGlib then glib else glib')
115 ];
116
117 mesonFlags = [
118 "--datadir=${placeholder "dev"}/share"
119 "-Dcairo=disabled"
120 "-Dgtk_doc=${lib.boolToString (stdenv.hostPlatform == stdenv.buildPlatform)}"
121 ]
122 ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
123 "-Dgi_cross_ldd_wrapper=${
124 replaceVarsWith {
125 name = "g-ir-scanner-lddwrapper";
126 isExecutable = true;
127 src = ./wrappers/g-ir-scanner-lddwrapper.sh;
128 replacements = {
129 inherit (buildPackages) bash;
130 buildlddtree = "${buildPackages.pax-utils}/bin/lddtree";
131 };
132 }
133 }"
134 "-Dgi_cross_binary_wrapper=${stdenv.hostPlatform.emulator buildPackages}"
135 # can't use canExecute, we need prebuilt when cross
136 ]
137 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
138 "-Dgi_cross_use_prebuilt_gi=true"
139 ];
140
141 doCheck = !stdenv.hostPlatform.isAarch64;
142
143 # During configurePhase, two python scripts are generated and need this. See
144 # https://github.com/NixOS/nixpkgs/pull/98316#issuecomment-695785692
145 postConfigure = ''
146 patchShebangs tools/*
147 '';
148
149 postInstall = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
150 cp -r ${buildPackages.gobject-introspection-unwrapped.devdoc} $devdoc
151 # these are uncompiled c and header files which aren't installed when cross-compiling because
152 # code that installs them is in tests/meson.build which is only run when not cross-compiling
153 # pygobject3 needs them
154 cp -r ${buildPackages.gobject-introspection-unwrapped.dev}/share/gobject-introspection-1.0/tests $dev/share/gobject-introspection-1.0/tests
155 '';
156
157 preCheck = ''
158 # Our gobject-introspection patches make the shared library paths absolute
159 # in the GIR files. When running tests, the library is not yet installed,
160 # though, so we need to replace the absolute path with a local one during build.
161 # We are using a symlink that we will delete before installation.
162 mkdir -p $out/lib
163 ln -s $PWD/tests/scanner/libregress-1.0${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libregress-1.0${stdenv.hostPlatform.extensions.sharedLibrary}
164 '';
165
166 postCheck = ''
167 rm $out/lib/libregress-1.0${stdenv.hostPlatform.extensions.sharedLibrary}
168 '';
169
170 setupHook = ./setup-hook.sh;
171
172 passthru = {
173 updateScript = gnome.updateScript {
174 packageName = "gobject-introspection";
175 versionPolicy = "odd-unstable";
176 };
177 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
178 };
179
180 meta = with lib; {
181 description = "Middleware layer between C libraries and language bindings";
182 homepage = "https://gi.readthedocs.io/";
183 maintainers = with maintainers; [
184 lovek323
185 artturin
186 ];
187 teams = [ teams.gnome ];
188 pkgConfigModules = [ "gobject-introspection-1.0" ];
189 platforms = platforms.unix;
190 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
191 license = with licenses; [
192 gpl2
193 lgpl2
194 ];
195
196 longDescription = ''
197 GObject introspection is a middleware layer between C libraries (using
198 GObject) and language bindings. The C library can be scanned at compile
199 time and generate a metadata file, in addition to the actual native C
200 library. Then at runtime, language bindings can read this metadata and
201 automatically provide bindings to call into the C library.
202 '';
203 };
204})