cross: simplify the blueprint-compiler patching

This commit is contained in:
2024-10-08 11:59:35 +00:00
parent 801cdd424e
commit adb2301fd5

View File

@@ -67,6 +67,21 @@ let
# try to load gobject-introspection files for the wrong platform (e.g. `blueprint` compiler).
typelibPath = pkgs: lib.concatStringsSep ":" (builtins.map (p: "${lib.getLib p}/lib/girepository-1.0") pkgs);
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host.
# wrap it so that it accesses the build-time GIR, whatever those are for some derivation
# wrapBlueprint = typelibs: final.buildPackages.blueprint-compiler.overrideAttrs (upstream: {
# nativeBuildInputs = (upstream.nativeBuildInputs or []) ++ [
# final.buildPackages.makeShellWrapper
# ];
# postInstall = (upstream.postInstall or "") + ''
# wrapProgram $out/bin/blueprint-compiler --set GI_TYPELIB_PATH ${typelibPath typelibs}
# '';
# });
wrapBlueprint = typelibs: final.buildPackages.writeShellScriptBin "blueprint-compiler" ''
export GI_TYPELIB_PATH=${typelibPath typelibs}
exec ${lib.getExe final.buildPackages.blueprint-compiler} "$@"
'';
# `cargo` which adds the correct env vars and `--target` flag when invoked from meson build scripts
crossCargo = let
inherit (final.pkgsBuildHost) cargo;
@@ -196,21 +211,17 @@ in with final; {
});
# 2024/08/12: upstreaming is unblocked
dialect = prev.dialect.overrideAttrs (upstream: {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host.
postPatch = (upstream.postPatch or "") + ''
substituteInPlace data/resources/meson.build --replace-fail \
"find_program('blueprint-compiler')" \
"'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
]}', find_program('blueprint-compiler')"
'';
dialect = (prev.dialect.override {
blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
];
}).overrideAttrs (upstream: {
# error: "<dialect> is not allowed to refer to the following paths: <build python>"
# dialect's meson build script sets host binaries to use build PYTHON
# disallowedReferences = [];
@@ -322,22 +333,17 @@ in with final; {
# };
# });
flare-signal-nixified = prev.flare-signal-nixified.overrideAttrs (upstream: {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host.
postPatch = (upstream.postPatch or "") + ''
substituteInPlace data/resources/meson.build --replace-fail \
"find_program('blueprint-compiler', version: '>= 0.12.0')" \
"'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
]}', find_program('blueprint-compiler')"
'';
});
flare-signal-nixified = prev.flare-signal-nixified.override {
blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
];
};
# 2024/08/12: upstreaming is blocked by xdg-desktop-portal
fractal = prev.fractal.overrideAttrs (upstream: {
@@ -394,22 +400,17 @@ in with final; {
# });
# 2024/09/01: upstreaming is blocked on qtx11extras (via zbar)
gnome-frog = prev.gnome-frog.overrideAttrs (upstream: {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host.
postPatch = (upstream.postPatch or "") + ''
substituteInPlace data/meson.build --replace-fail \
"find_program('blueprint-compiler')" \
"'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
]}', find_program('blueprint-compiler')"
'';
});
gnome-frog = prev.gnome-frog.override {
blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
];
};
gnome-maps = prev.gnome-maps.overrideAttrs (upstream: {
# 2024/08/12: upstreaming is blocked by libgweather (direct dependency)
@@ -572,22 +573,17 @@ in with final; {
# });
# 2024/08/12: upstreaming is unblocked
komikku = prev.komikku.overrideAttrs (upstream: {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host.
postPatch = (upstream.postPatch or "") + ''
substituteInPlace data/meson.build --replace-fail \
"find_program('blueprint-compiler')" \
"'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
]}', find_program('blueprint-compiler')"
'';
});
komikku = prev.komikku.override {
blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
];
};
# 2024/08/12: upstreaming is unblocked -- but is this necessary?
# koreader = prev.koreader.overrideAttrs (upstream: {
@@ -757,21 +753,18 @@ in with final; {
# 2024/08/12: upstreaming is unblocked
newsflash = (prev.newsflash.override {
blueprint-compiler = buildPackages.writeShellScriptBin "blueprint-compiler" ''
export GI_TYPELIB_PATH=${typelibPath [
buildPackages.clapper
buildPackages.glib
buildPackages.gtk4
buildPackages.gst_all_1.gstreamer
buildPackages.gst_all_1.gst-plugins-base
buildPackages.gdk-pixbuf
buildPackages.pango
buildPackages.graphene
buildPackages.harfbuzz
buildPackages.libadwaita
]}
exec ${lib.getExe buildPackages.blueprint-compiler} "$@"
'';
blueprint-compiler = wrapBlueprint [
buildPackages.clapper
buildPackages.glib
buildPackages.gtk4
buildPackages.gst_all_1.gstreamer
buildPackages.gst_all_1.gst-plugins-base
buildPackages.gdk-pixbuf
buildPackages.pango
buildPackages.graphene
buildPackages.harfbuzz
buildPackages.libadwaita
];
cargo = crossCargo; #< fixes openssl not being able to find its library
}).overrideAttrs (upstream: {
postPatch = (upstream.postPatch or "") + ''
@@ -1044,21 +1037,20 @@ in with final; {
});
# 2024/08/12: upstreaming is unblocked
spot = (prev.spot.override { cargo = crossCargo; }).overrideAttrs (upstream: {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host.
spot = (prev.spot.override {
blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
];
cargo = crossCargo;
}).overrideAttrs (upstream: {
postPatch = (upstream.postPatch or "") + ''
substituteInPlace src/meson.build \
--replace-fail \
"find_program('blueprint-compiler')" \
"'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
]}', find_program('blueprint-compiler')" \
--replace-fail \
"meson.project_build_root() / cargo_output" \
"meson.project_build_root() / 'src' / '${rust.envVars.rustHostPlatformSpec}' / rust_target / meson.project_name()"
@@ -1110,20 +1102,23 @@ in with final; {
# });
# 2024/08/12: upstreaming is unblocked
tangram = prev.tangram.overrideAttrs (upstream: {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host.
# additionally, gsjpack has a shebang for the host gjs. patchShebangs --build doesn't fix that: just manually specify the build gjs
tangram = (prev.tangram.override {
blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
];
}).overrideAttrs (upstream: {
# gsjpack has a shebang for the host gjs. patchShebangs --build doesn't fix that: just manually specify the build gjs
postPatch = (upstream.postPatch or "") + ''
substituteInPlace src/meson.build \
--replace-fail "find_program('gjs').full_path()" "'${gjs}/bin/gjs'" \
--replace-fail "gjspack," "'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
]}', '${buildPackages.gjs}/bin/gjs', '-m', gjspack,"
'';
});