···155156#### Package using Meson needs to run binaries for the host platform during build. {#cross-meson-runs-host-code}
157158-Add `mesonEmulatorHook` cross conditionally to `nativeBuildInputs`.
159160e.g.
161162```
163nativeBuildInputs = [
164 meson
165-] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
166 mesonEmulatorHook
167];
168```
···155156#### Package using Meson needs to run binaries for the host platform during build. {#cross-meson-runs-host-code}
157158+Add `mesonEmulatorHook` to `nativeBuildInputs` conditionally on if the target binaries can be executed.
159160e.g.
161162```
163nativeBuildInputs = [
164 meson
165+] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
166 mesonEmulatorHook
167];
168```
···27# it may be worth thinking about using multiple derivation outputs
28# In that case its about 6MB which could be separated
2930-stdenv.mkDerivation rec {
31 pname = "gobject-introspection";
32 version = "1.72.0";
33···37 outputBin = "dev";
3839 src = fetchurl {
40- url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
41 sha256 = "Av6OWQhh2I+DBg3TnNpcyqYLLaHSHQ+VSZMBsYa+qrw=";
42 };
43···68 docbook-xsl-nons
69 docbook_xml_dtd_45
70 python3
71- setupHook # move .gir files
72 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ gobject-introspection-unwrapped ];
7374 buildInputs = [
···105106 postInstall = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
107 cp -r ${buildPackages.gobject-introspection-unwrapped.devdoc} $devdoc
0000108 '';
109110 preCheck = ''
···120 rm $out/lib/libregress-1.0${stdenv.targetPlatform.extensions.sharedLibrary}
121 '';
1220000000000123 setupHook = ./setup-hook.sh;
124125 passthru = {
126 updateScript = gnome.updateScript {
127- packageName = pname;
128 versionPolicy = "odd-unstable";
129 };
130 };
···144 automatically provide bindings to call into the C library.
145 '';
146 };
147-}
···27# it may be worth thinking about using multiple derivation outputs
28# In that case its about 6MB which could be separated
2930+stdenv.mkDerivation (finalAttrs: {
31 pname = "gobject-introspection";
32 version = "1.72.0";
33···37 outputBin = "dev";
3839 src = fetchurl {
40+ url = "mirror://gnome/sources/gobject-introspection/${lib.versions.majorMinor finalAttrs.version}/gobject-introspection-${finalAttrs.version}.tar.xz";
41 sha256 = "Av6OWQhh2I+DBg3TnNpcyqYLLaHSHQ+VSZMBsYa+qrw=";
42 };
43···68 docbook-xsl-nons
69 docbook_xml_dtd_45
70 python3
71+ finalAttrs.setupHook # move .gir files
72 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ gobject-introspection-unwrapped ];
7374 buildInputs = [
···105106 postInstall = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
107 cp -r ${buildPackages.gobject-introspection-unwrapped.devdoc} $devdoc
108+ # these are uncompiled c and header files which aren't installed when cross-compiling because
109+ # code that installs them is in tests/meson.build which is only run when not cross-compiling
110+ # pygobject3 needs them
111+ cp -r ${buildPackages.gobject-introspection-unwrapped.dev}/share/gobject-introspection-1.0/tests $dev/share/gobject-introspection-1.0/tests
112 '';
113114 preCheck = ''
···124 rm $out/lib/libregress-1.0${stdenv.targetPlatform.extensions.sharedLibrary}
125 '';
126127+ # when cross-compiling and using the wrapper then when a package looks up the g_ir_X
128+ # variable with pkg-config they'll get the host version which can't be run
129+ # switch the variables to use g_ir_X from path instead of an absolute path
130+ postFixup = lib.optionalString (!lib.hasSuffix "wrapped" finalAttrs.pname) ''
131+ find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do
132+ substituteInPlace "$pc" \
133+ --replace '=''${bindir}/g-ir' '=g-ir'
134+ done
135+ '';
136+137 setupHook = ./setup-hook.sh;
138139 passthru = {
140 updateScript = gnome.updateScript {
141+ packageName = "gobject-introspection";
142 versionPolicy = "odd-unstable";
143 };
144 };
···158 automatically provide bindings to call into the C library.
159 '';
160 };
161+})
···10 fi
11}
1213-addEnvHooks "$hostOffset" make_gobject_introspection_find_gir_files
1415giDiscoverSelf() {
16 if [ -d "$prefix/lib/girepository-1.0" ]; then
···10 fi
11}
1213+addEnvHooks "$targetOffset" make_gobject_introspection_find_gir_files
1415giDiscoverSelf() {
16 if [ -d "$prefix/lib/girepository-1.0" ]; then
···121 ];
122123 buildInputs = [
0124 gst-plugins-base
125 orc
126- # gobject-introspection has to be in both nativeBuildInputs and
127- # buildInputs. The build tries to link against libgirepository-1.0.so
128- gobject-introspection
129 json-glib
130 ldacbt
131 libass
···294 # `applemedia/videotexturecache.h` requires `gst/gl/gl.h`,
295 # but its meson build system does not declare the dependency.
296 "-Dapplemedia=disabled"
297- ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
298- "-Dintrospection=disabled"
299 ] ++ (if enableGplPlugins then [
300 "-Dgpl=enabled"
301 ] else [
···121 ];
122123 buildInputs = [
124+ gobject-introspection
125 gst-plugins-base
126 orc
000127 json-glib
128 ldacbt
129 libass
···292 # `applemedia/videotexturecache.h` requires `gst/gl/gl.h`,
293 # but its meson build system does not declare the dependency.
294 "-Dapplemedia=disabled"
00295 ] ++ (if enableGplPlugins then [
296 "-Dgpl=enabled"
297 ] else [
···12, ninja
13, isPy3k
14, gnome
15+, python
16}:
1718buildPythonPackage rec {
···30 sha256 = "HzS192JN415E61p+tCg1MoW9AwBNVRMaX39/qbkPPMk=";
31 };
3233+ depsBuildBuild = [
34+ pkg-config
35+ ];
36+37 nativeBuildInputs = [
38 pkg-config
39 meson
···42 ];
4344 buildInputs = [
45+ # # .so files link to these
46+ gobject-introspection
47 glib
048 ] ++ lib.optionals stdenv.isDarwin [
49 ncurses
50 ];
···52 propagatedBuildInputs = [
53 pycairo
54 cairo
55+ ];
56+57+ mesonFlags = [
58+ # This is only used for figuring out what version of Python is in
59+ # use, and related stuff like figuring out what the install prefix
60+ # should be, but it does need to be able to execute Python code.
61+ "-Dpython=${python.pythonForBuild.interpreter}"
62 ];
6364 passthru = {
···34, iputils
35, kmod
36, jansson
37+, elfutils
38, gtk-doc
39, libxslt
40, docbook_xsl
···44, openconnect
45, curl
46, meson
47+, mesonEmulatorHook
48, ninja
49, libpsl
50, mobile-broadband-provider-info
51, runtimeShell
52+, buildPackages
53}:
5455let
56+ pythonForDocs = python3.pythonForBuild.withPackages (pkgs: with pkgs; [ pygobject3 ]);
57in
58stdenv.mkDerivation rec {
59 pname = "networkmanager";
···105 "-Ddhcpcanon=no"
106107 # Miscellaneous
108+ # almost cross-compiles, however fails with
109+ # ** (process:9234): WARNING **: Failed to load shared library '/nix/store/...-networkmanager-aarch64-unknown-linux-gnu-1.38.2/lib/libnm.so.0' referenced by the typelib: /nix/store/...-networkmanager-aarch64-unknown-linux-gnu-1.38.2/lib/libnm.so.0: cannot open shared object file: No such file or directory
110+ "-Ddocs=${lib.boolToString (stdenv.buildPlatform == stdenv.hostPlatform)}"
111 # We don't use firewalld in NixOS
112 "-Dfirewalld_zone=false"
113 "-Dtests=no"
···143 ];
144145 buildInputs = [
146+ gobject-introspection
147 systemd
148 libselinux
149 audit
···156 mobile-broadband-provider-info
157 bluez5
158 dnsmasq
0159 modemmanager
160 readline
161 newt
162 libsoup
163 jansson
164+ dbus # used to get directory paths with pkg-config during configuration
165 ];
166167 propagatedBuildInputs = [ gnutls libgcrypt ];
···173 pkg-config
174 vala
175 gobject-introspection
176+ elfutils # used to find jansson soname
177 # Docs
178 gtk-doc
179 libxslt
···182 docbook_xml_dtd_42
183 docbook_xml_dtd_43
184 pythonForDocs
185+ ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
186+ mesonEmulatorHook
187 ];
188189 doCheck = false; # requires /sys, the net
···191 postPatch = ''
192 patchShebangs ./tools
193 patchShebangs libnm/generate-setting-docs.py
194+195+ # TODO: submit upstream
196+ substituteInPlace meson.build \
197+ --replace "'vala', req" "'vala', native: false, req"
198 '';
199200 preBuild = ''
···204 # We are using a symlink that will be overridden during installation.
205 mkdir -p ${placeholder "out"}/lib
206 ln -s $PWD/src/libnm-client-impl/libnm.so.0 ${placeholder "out"}/lib/libnm.so.0
207+ '';
208+209+ postFixup = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
210+ cp -r ${buildPackages.networkmanager.devdoc} $devdoc
211+ cp -r ${buildPackages.networkmanager.man} $man
212 '';
213214 passthru = {
+3-3
pkgs/top-level/all-packages.nix
···4148 # example of an error which this fixes
4149 # [Errno 8] Exec format error: './gdk3-scan'
4150 mesonEmulatorHook =
4151- if (stdenv.buildPlatform != stdenv.targetPlatform) then
4152 makeSetupHook
4153 {
4154 name = "mesonEmulatorHook";
···4159 '';
4160 };
4161 } ../development/tools/build-managers/meson/emulator-hook.sh
4162- else throw "mesonEmulatorHook has to be in a cross conditional i.e. (stdenv.buildPlatform != stdenv.hostPlatform)";
41634164 meson-tools = callPackage ../misc/meson-tools { };
4165···17943 gns3-gui = gns3Packages.guiStable;
17944 gns3-server = gns3Packages.serverStable;
1794517946- gobject-introspection = if (stdenv.hostPlatform != stdenv.targetPlatform)
17947 then callPackage ../development/libraries/gobject-introspection/wrapper.nix { } else gobject-introspection-unwrapped;
1794817949 gobject-introspection-unwrapped = callPackage ../development/libraries/gobject-introspection {
···4148 # example of an error which this fixes
4149 # [Errno 8] Exec format error: './gdk3-scan'
4150 mesonEmulatorHook =
4151+ if (!stdenv.buildPlatform.canExecute stdenv.targetPlatform) then
4152 makeSetupHook
4153 {
4154 name = "mesonEmulatorHook";
···4159 '';
4160 };
4161 } ../development/tools/build-managers/meson/emulator-hook.sh
4162+ else throw "mesonEmulatorHook has to be in a conditional to check if the target binaries can be executed i.e. (!stdenv.buildPlatform.canExecute stdenv.hostPlatform)";
41634164 meson-tools = callPackage ../misc/meson-tools { };
4165···17943 gns3-gui = gns3Packages.guiStable;
17944 gns3-server = gns3Packages.serverStable;
1794517946+ gobject-introspection = if (!stdenv.hostPlatform.canExecute stdenv.targetPlatform)
17947 then callPackage ../development/libraries/gobject-introspection/wrapper.nix { } else gobject-introspection-unwrapped;
1794817949 gobject-introspection-unwrapped = callPackage ../development/libraries/gobject-introspection {