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). # 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); 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 # `cargo` which adds the correct env vars and `--target` flag when invoked from meson build scripts
crossCargo = let crossCargo = let
inherit (final.pkgsBuildHost) cargo; inherit (final.pkgsBuildHost) cargo;
@@ -196,12 +211,8 @@ in with final; {
}); });
# 2024/08/12: upstreaming is unblocked # 2024/08/12: upstreaming is unblocked
dialect = prev.dialect.overrideAttrs (upstream: { dialect = (prev.dialect.override {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host. blueprint-compiler = wrapBlueprint [
postPatch = (upstream.postPatch or "") + ''
substituteInPlace data/resources/meson.build --replace-fail \
"find_program('blueprint-compiler')" \
"'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf buildPackages.gdk-pixbuf
buildPackages.glib buildPackages.glib
buildPackages.graphene buildPackages.graphene
@@ -209,8 +220,8 @@ in with final; {
buildPackages.harfbuzz buildPackages.harfbuzz
buildPackages.libadwaita buildPackages.libadwaita
buildPackages.pango buildPackages.pango
]}', find_program('blueprint-compiler')" ];
''; }).overrideAttrs (upstream: {
# error: "<dialect> is not allowed to refer to the following paths: <build python>" # 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 # dialect's meson build script sets host binaries to use build PYTHON
# disallowedReferences = []; # disallowedReferences = [];
@@ -322,12 +333,8 @@ in with final; {
# }; # };
# }); # });
flare-signal-nixified = prev.flare-signal-nixified.overrideAttrs (upstream: { flare-signal-nixified = prev.flare-signal-nixified.override {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host. blueprint-compiler = wrapBlueprint [
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.gdk-pixbuf
buildPackages.glib buildPackages.glib
buildPackages.graphene buildPackages.graphene
@@ -335,9 +342,8 @@ in with final; {
buildPackages.harfbuzz buildPackages.harfbuzz
buildPackages.libadwaita buildPackages.libadwaita
buildPackages.pango buildPackages.pango
]}', find_program('blueprint-compiler')" ];
''; };
});
# 2024/08/12: upstreaming is blocked by xdg-desktop-portal # 2024/08/12: upstreaming is blocked by xdg-desktop-portal
fractal = prev.fractal.overrideAttrs (upstream: { fractal = prev.fractal.overrideAttrs (upstream: {
@@ -394,12 +400,8 @@ in with final; {
# }); # });
# 2024/09/01: upstreaming is blocked on qtx11extras (via zbar) # 2024/09/01: upstreaming is blocked on qtx11extras (via zbar)
gnome-frog = prev.gnome-frog.overrideAttrs (upstream: { gnome-frog = prev.gnome-frog.override {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host. blueprint-compiler = wrapBlueprint [
postPatch = (upstream.postPatch or "") + ''
substituteInPlace data/meson.build --replace-fail \
"find_program('blueprint-compiler')" \
"'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf buildPackages.gdk-pixbuf
buildPackages.glib buildPackages.glib
buildPackages.graphene buildPackages.graphene
@@ -407,9 +409,8 @@ in with final; {
buildPackages.harfbuzz buildPackages.harfbuzz
buildPackages.libadwaita buildPackages.libadwaita
buildPackages.pango buildPackages.pango
]}', find_program('blueprint-compiler')" ];
''; };
});
gnome-maps = prev.gnome-maps.overrideAttrs (upstream: { gnome-maps = prev.gnome-maps.overrideAttrs (upstream: {
# 2024/08/12: upstreaming is blocked by libgweather (direct dependency) # 2024/08/12: upstreaming is blocked by libgweather (direct dependency)
@@ -572,12 +573,8 @@ in with final; {
# }); # });
# 2024/08/12: upstreaming is unblocked # 2024/08/12: upstreaming is unblocked
komikku = prev.komikku.overrideAttrs (upstream: { komikku = prev.komikku.override {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host. blueprint-compiler = wrapBlueprint [
postPatch = (upstream.postPatch or "") + ''
substituteInPlace data/meson.build --replace-fail \
"find_program('blueprint-compiler')" \
"'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf buildPackages.gdk-pixbuf
buildPackages.glib buildPackages.glib
buildPackages.graphene buildPackages.graphene
@@ -585,9 +582,8 @@ in with final; {
buildPackages.harfbuzz buildPackages.harfbuzz
buildPackages.libadwaita buildPackages.libadwaita
buildPackages.pango buildPackages.pango
]}', find_program('blueprint-compiler')" ];
''; };
});
# 2024/08/12: upstreaming is unblocked -- but is this necessary? # 2024/08/12: upstreaming is unblocked -- but is this necessary?
# koreader = prev.koreader.overrideAttrs (upstream: { # koreader = prev.koreader.overrideAttrs (upstream: {
@@ -757,8 +753,7 @@ in with final; {
# 2024/08/12: upstreaming is unblocked # 2024/08/12: upstreaming is unblocked
newsflash = (prev.newsflash.override { newsflash = (prev.newsflash.override {
blueprint-compiler = buildPackages.writeShellScriptBin "blueprint-compiler" '' blueprint-compiler = wrapBlueprint [
export GI_TYPELIB_PATH=${typelibPath [
buildPackages.clapper buildPackages.clapper
buildPackages.glib buildPackages.glib
buildPackages.gtk4 buildPackages.gtk4
@@ -769,9 +764,7 @@ in with final; {
buildPackages.graphene buildPackages.graphene
buildPackages.harfbuzz buildPackages.harfbuzz
buildPackages.libadwaita buildPackages.libadwaita
]} ];
exec ${lib.getExe buildPackages.blueprint-compiler} "$@"
'';
cargo = crossCargo; #< fixes openssl not being able to find its library cargo = crossCargo; #< fixes openssl not being able to find its library
}).overrideAttrs (upstream: { }).overrideAttrs (upstream: {
postPatch = (upstream.postPatch or "") + '' postPatch = (upstream.postPatch or "") + ''
@@ -1044,13 +1037,8 @@ in with final; {
}); });
# 2024/08/12: upstreaming is unblocked # 2024/08/12: upstreaming is unblocked
spot = (prev.spot.override { cargo = crossCargo; }).overrideAttrs (upstream: { spot = (prev.spot.override {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host. blueprint-compiler = wrapBlueprint [
postPatch = (upstream.postPatch or "") + ''
substituteInPlace src/meson.build \
--replace-fail \
"find_program('blueprint-compiler')" \
"'env', 'GI_TYPELIB_PATH=${typelibPath [
buildPackages.gdk-pixbuf buildPackages.gdk-pixbuf
buildPackages.glib buildPackages.glib
buildPackages.graphene buildPackages.graphene
@@ -1058,7 +1046,11 @@ in with final; {
buildPackages.harfbuzz buildPackages.harfbuzz
buildPackages.libadwaita buildPackages.libadwaita
buildPackages.pango buildPackages.pango
]}', find_program('blueprint-compiler')" \ ];
cargo = crossCargo;
}).overrideAttrs (upstream: {
postPatch = (upstream.postPatch or "") + ''
substituteInPlace src/meson.build \
--replace-fail \ --replace-fail \
"meson.project_build_root() / cargo_output" \ "meson.project_build_root() / cargo_output" \
"meson.project_build_root() / 'src' / '${rust.envVars.rustHostPlatformSpec}' / rust_target / meson.project_name()" "meson.project_build_root() / 'src' / '${rust.envVars.rustHostPlatformSpec}' / rust_target / meson.project_name()"
@@ -1110,13 +1102,8 @@ in with final; {
# }); # });
# 2024/08/12: upstreaming is unblocked # 2024/08/12: upstreaming is unblocked
tangram = prev.tangram.overrideAttrs (upstream: { tangram = (prev.tangram.override {
# blueprint-compiler runs on the build machine, but tries to load gobject-introspection types meant for the host. blueprint-compiler = wrapBlueprint [
# additionally, 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.gdk-pixbuf
buildPackages.glib buildPackages.glib
buildPackages.graphene buildPackages.graphene
@@ -1124,6 +1111,14 @@ in with final; {
buildPackages.harfbuzz buildPackages.harfbuzz
buildPackages.libadwaita buildPackages.libadwaita
buildPackages.pango 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.glib
]}', '${buildPackages.gjs}/bin/gjs', '-m', gjspack," ]}', '${buildPackages.gjs}/bin/gjs', '-m', gjspack,"
''; '';
}); });