cross: tidy up the blueprint-compiler patches

deployed and *seems* to be working; i ought to be able to turn these into proper patches over the next few days
This commit is contained in:
2025-04-20 08:13:42 +00:00
parent a099279a7a
commit a13feca385

View File

@@ -49,19 +49,35 @@ let
addDepsBuildBuild = depsBuildBuild: addInputs { inherit depsBuildBuild; }; addDepsBuildBuild = depsBuildBuild: addInputs { inherit depsBuildBuild; };
mvToNativeInputs = nativeBuildInputs: mvInputs { inherit nativeBuildInputs; }; mvToNativeInputs = nativeBuildInputs: mvInputs { inherit nativeBuildInputs; };
mvToBuildInputs = buildInputs: mvInputs { inherit buildInputs; }; mvToBuildInputs = buildInputs: mvInputs { inherit buildInputs; };
rmInputs = { buildInputs ? [], nativeBuildInputs ? [] }: pkg: pkg.overrideAttrs (upstream: { mvToDepsBuildBuild = depsBuildBuild: mvInputs { inherit depsBuildBuild; };
buildInputs = lib.subtractLists buildInputs (upstream.buildInputs or []); rmInputs = { buildInputs ? [], depsBuildBuild ? [], nativeBuildInputs ? [] }: pkg: pkg.overrideAttrs (upstream: {
nativeBuildInputs = lib.subtractLists nativeBuildInputs (upstream.nativeBuildInputs or []); buildInputs = lib.filter
(p: !lib.any (rm: p == rm || (p ? name && rm ? name && p.name == rm.name)) buildInputs)
(upstream.buildInputs or [])
;
depsBuildBuild = lib.filter
(p: !lib.any (rm: p == rm || (p ? name && rm ? name && p.name == rm.name)) depsBuildBuild)
(upstream.depsBuildBuild or [])
;
nativeBuildInputs = lib.filter
(p: !lib.any (rm: p == rm || (p ? name && rm ? name && p.name == rm.name)) nativeBuildInputs)
(upstream.nativeBuildInputs or [])
;
}); });
rmBuildInputs = buildInputs: rmInputs { inherit buildInputs; }; rmBuildInputs = buildInputs: rmInputs { inherit buildInputs; };
rmNativeInputs = nativeBuildInputs: rmInputs { inherit nativeBuildInputs; }; rmNativeInputs = nativeBuildInputs: rmInputs { inherit nativeBuildInputs; };
# move items from buildInputs into nativeBuildInputs, or vice-versa. # move items from buildInputs into nativeBuildInputs, or vice-versa.
# arguments represent the final location of specific inputs. # arguments represent the final location of specific inputs.
mvInputs = { buildInputs ? [], nativeBuildInputs ? [] }: pkg: mvInputs = { buildInputs ? [], depsBuildBuild ? [], nativeBuildInputs ? [] }: pkg:
addInputs { buildInputs = buildInputs; nativeBuildInputs = nativeBuildInputs; } addInputs { inherit buildInputs depsBuildBuild nativeBuildInputs; }
( (
rmInputs { buildInputs = nativeBuildInputs; nativeBuildInputs = buildInputs; } rmInputs
pkg {
buildInputs = depsBuildBuild ++ nativeBuildInputs;
depsBuildBuild = buildInputs ++ nativeBuildInputs;
nativeBuildInputs = buildInputs ++ depsBuildBuild;
}
pkg
); );
# build a GI_TYPELIB_PATH out of some packages, useful for build-time tools which otherwise # build a GI_TYPELIB_PATH out of some packages, useful for build-time tools which otherwise
@@ -83,6 +99,32 @@ let
exec ${lib.getExe final.buildPackages.blueprint-compiler} "$@" exec ${lib.getExe final.buildPackages.blueprint-compiler} "$@"
''; '';
# use like: `p.override { blueprint-compiler = crossBlueprint; }`
crossBlueprint = final.pkgsBuildBuild.blueprint-compiler.overrideAttrs (upstream: {
# blueprint-compiler isn't invokable in a standalone environment.
# i.e. `blueprint-compiler --help` fails.
# fix by adding glib typelib.
# TODO: upstream! (see `wip-blueprint-compiler` nixpkgs branch)
nativeBuildInputs = (upstream.nativeBuildInputs or []) ++ [
final.pkgsBuildBuild.makeWrapper
];
postFixup = (upstream.postFixup or "") + ''
wrapProgram $out/bin/blueprint-compiler \
--prefix GI_TYPELIB_PATH : "${lib.getLib final.pkgsBuildBuild.glib}/lib/girepository-1.0:${lib.getLib final.pkgsBuildBuild.gobject-introspection}/lib/girepository-1.0"
'';
# propagate gobject-introspection such that it appears in the same host offset as us,
# and populates GI_TYPELIB_PATH with the correct offset.
propagatedBuildInputs = [];
depsTargetTargetPropagated = [ final.gobject-introspection ];
});
# build a blueprint-based package in a way that is cross-compatible
# fixBlueprint = p: mvToDepsBuildBuild [ crossBlueprint ] p;
fixBlueprint = p: p.override {
blueprint-compiler = crossBlueprint;
};
# `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;
@@ -179,30 +221,32 @@ in with final; {
# shell = runtimeShell; # shell = runtimeShell;
# }; # };
blanket = prev.blanket.override { blanket = fixBlueprint prev.blanket;
blueprint-compiler = wrapBlueprint [ # blanket = prev.blanket.override {
buildPackages.gdk-pixbuf # blueprint-compiler = wrapBlueprint [
buildPackages.glib # buildPackages.gdk-pixbuf
buildPackages.graphene # buildPackages.glib
buildPackages.gtk4 # buildPackages.graphene
buildPackages.harfbuzz # buildPackages.gtk4
buildPackages.libadwaita # buildPackages.harfbuzz
buildPackages.pango # buildPackages.libadwaita
]; # buildPackages.pango
}; # ];
# };
# 2025/02/04: upstreaming is unblocked, but a cleaner solution than this doesn't seem to exist yet # 2025/02/04: upstreaming is unblocked, but a cleaner solution than this doesn't seem to exist yet
confy = (prev.confy.override { # confy = (prev.confy.override {
blueprint-compiler = wrapBlueprint [ # blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf # buildPackages.gdk-pixbuf
buildPackages.glib # buildPackages.glib
buildPackages.graphene # buildPackages.graphene
buildPackages.gtk4 # buildPackages.gtk4
buildPackages.harfbuzz # buildPackages.harfbuzz
buildPackages.libadwaita # buildPackages.libadwaita
buildPackages.pango # buildPackages.pango
]; # ];
}).overrideAttrs (upstream: { # }).overrideAttrs (upstream: {
confy = (fixBlueprint prev.confy).overrideAttrs (upstream: {
# meson's `python.find_installation` method somehow just doesn't support cross compilation. # meson's `python.find_installation` method somehow just doesn't support cross compilation.
# - <https://mesonbuild.com/Python-module.html#find_installation> # - <https://mesonbuild.com/Python-module.html#find_installation>
# so, build it to target build python, then patch in the host python # so, build it to target build python, then patch in the host python
@@ -230,17 +274,18 @@ in with final; {
}); });
# 2024/11/19: upstreaming is unblocked # 2024/11/19: upstreaming is unblocked
dialect = (prev.dialect.override { # dialect = (prev.dialect.override {
blueprint-compiler = wrapBlueprint [ # blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf # buildPackages.gdk-pixbuf
buildPackages.glib # buildPackages.glib
buildPackages.graphene # buildPackages.graphene
buildPackages.gtk4 # buildPackages.gtk4
buildPackages.harfbuzz # buildPackages.harfbuzz
buildPackages.libadwaita # buildPackages.libadwaita
buildPackages.pango # buildPackages.pango
]; # ];
}).overrideAttrs (upstream: { # }).overrideAttrs (upstream: {
dialect = (fixBlueprint prev.dialect).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 = [];
@@ -332,17 +377,18 @@ in with final; {
# }; # };
# }); # });
flare-signal-nixified = prev.flare-signal-nixified.override { flare-signal-nixified = fixBlueprint prev.flare-signal-nixified;
blueprint-compiler = wrapBlueprint [ # flare-signal-nixified = prev.flare-signal-nixified.override {
buildPackages.gdk-pixbuf # blueprint-compiler = wrapBlueprint [
buildPackages.glib # buildPackages.gdk-pixbuf
buildPackages.graphene # buildPackages.glib
buildPackages.gtk4 # buildPackages.graphene
buildPackages.harfbuzz # buildPackages.gtk4
buildPackages.libadwaita # buildPackages.harfbuzz
buildPackages.pango # buildPackages.libadwaita
]; # buildPackages.pango
}; # ];
# };
# 2025/01/13: upstreaming is blocked by glycin-loaders # 2025/01/13: upstreaming is blocked by glycin-loaders
fractal = prev.fractal.override { fractal = prev.fractal.override {
@@ -364,17 +410,18 @@ in with final; {
# }); # });
# 2024/11/19: upstreaming is blocked on qtx11extras (via zbar) # 2024/11/19: upstreaming is blocked on qtx11extras (via zbar)
gnome-frog = prev.gnome-frog.override { # gnome-frog = prev.gnome-frog.override {
blueprint-compiler = wrapBlueprint [ # blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf # buildPackages.gdk-pixbuf
buildPackages.glib # buildPackages.glib
buildPackages.graphene # buildPackages.graphene
buildPackages.gtk4 # buildPackages.gtk4
buildPackages.harfbuzz # buildPackages.harfbuzz
buildPackages.libadwaita # buildPackages.libadwaita
buildPackages.pango # buildPackages.pango
]; # ];
}; # };
gnome-frog = fixBlueprint prev.gnome-frog;
# 2025/01/13: upstreaming is blocked on gnome-shell # 2025/01/13: upstreaming is blocked on gnome-shell
# fixes: "gdbus-codegen not found or executable" # fixes: "gdbus-codegen not found or executable"
@@ -443,17 +490,18 @@ in with final; {
# }); # });
# 2024/11/19: upstreaming is unblocked # 2024/11/19: upstreaming is unblocked
komikku = prev.komikku.override { komikku = fixBlueprint prev.komikku;
blueprint-compiler = wrapBlueprint [ # komikku = prev.komikku.override {
buildPackages.gdk-pixbuf # blueprint-compiler = wrapBlueprint [
buildPackages.glib # buildPackages.gdk-pixbuf
buildPackages.graphene # buildPackages.glib
buildPackages.gtk4 # buildPackages.graphene
buildPackages.harfbuzz # buildPackages.gtk4
buildPackages.libadwaita # buildPackages.harfbuzz
buildPackages.pango # buildPackages.libadwaita
]; # buildPackages.pango
}; # ];
# };
# 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: {
@@ -524,20 +572,24 @@ in with final; {
# ncftp = addNativeInputs [ bintools ] prev.ncftp; # ncftp = addNativeInputs [ bintools ] prev.ncftp;
# 2025/04/04: upstreaming is unblocked # 2025/04/04: upstreaming is unblocked
# newsflash = (prev.newsflash.override {
# 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: {
newsflash = (prev.newsflash.override { newsflash = (prev.newsflash.override {
blueprint-compiler = wrapBlueprint [ blueprint-compiler = crossBlueprint;
buildPackages.clapper cargo = crossCargo;
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: { }).overrideAttrs (upstream: {
postPatch = (upstream.postPatch or "") + '' postPatch = (upstream.postPatch or "") + ''
rm build.rs rm build.rs
@@ -803,16 +855,20 @@ in with final; {
}; };
# 2025/04/04: upstreaming is unblocked # 2025/04/04: upstreaming is unblocked
# spot = prev.spot.override {
# blueprint-compiler = wrapBlueprint [
# buildPackages.gdk-pixbuf
# buildPackages.glib
# buildPackages.graphene
# buildPackages.gtk4
# buildPackages.harfbuzz
# buildPackages.libadwaita
# buildPackages.pango
# ];
# cargo = crossCargo;
# };
spot = prev.spot.override { spot = prev.spot.override {
blueprint-compiler = wrapBlueprint [ blueprint-compiler = crossBlueprint;
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
];
cargo = crossCargo; cargo = crossCargo;
}; };
@@ -861,25 +917,36 @@ in with final; {
# }); # });
# 2024/11/19: upstreaming is unblocked # 2024/11/19: upstreaming is unblocked
tangram = (prev.tangram.override { # tangram = (prev.tangram.override {
blueprint-compiler = wrapBlueprint [ # blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf # buildPackages.gdk-pixbuf
buildPackages.glib # buildPackages.glib
buildPackages.graphene # buildPackages.graphene
buildPackages.gtk4 # buildPackages.gtk4
buildPackages.harfbuzz # buildPackages.harfbuzz
buildPackages.libadwaita # buildPackages.libadwaita
buildPackages.pango # buildPackages.pango
]; # ];
}).overrideAttrs (upstream: { # }).overrideAttrs (upstream: {
tangram = (fixBlueprint prev.tangram).overrideAttrs (upstream: {
# gsjpack has a shebang for the host gjs. patchShebangs --build doesn't fix that: just manually specify the build gjs # gsjpack has a shebang for the host gjs. patchShebangs --build doesn't fix that: just manually specify the build gjs
postPatch = (upstream.postPatch or "") + '' postPatch = let
gjspack' = buildPackages.writeShellScriptBin "gjspack" ''
export GI_TYPELIB_PATH=${typelibPath [ buildPackages.glib ]}:$GI_TYPELIB_PATH
exec ${buildPackages.gjs}/bin/gjs $@
'';
in (upstream.postPatch or "") + ''
substituteInPlace src/meson.build \ substituteInPlace src/meson.build \
--replace-fail "find_program('gjs').full_path()" "'${gjs}/bin/gjs'" \ --replace-fail "find_program('gjs').full_path()" "'${gjs}/bin/gjs'" \
--replace-fail "gjspack," "'env', 'GI_TYPELIB_PATH=${typelibPath [ --replace-fail "gjspack," "'${gjspack'}/bin/gjspack', '-m', gjspack,"
buildPackages.glib
]}', '${buildPackages.gjs}/bin/gjs', '-m', gjspack,"
''; '';
# 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,"
# '';
}); });
# fixes: "ar: command not found" # fixes: "ar: command not found"
@@ -904,17 +971,21 @@ in with final; {
# }; # };
# 2025/01/13: upstreaming is unblocked # 2025/01/13: upstreaming is unblocked
# video-trimmer = prev.video-trimmer.override {
# blueprint-compiler = wrapBlueprint [
# buildPackages.gdk-pixbuf
# buildPackages.glib
# buildPackages.graphene
# buildPackages.gtk4
# buildPackages.harfbuzz
# buildPackages.libadwaita
# buildPackages.pango
# ];
# cargo = crossCargo;
# };
video-trimmer = prev.video-trimmer.override { video-trimmer = prev.video-trimmer.override {
blueprint-compiler = wrapBlueprint [
buildPackages.gdk-pixbuf
buildPackages.glib
buildPackages.graphene
buildPackages.gtk4
buildPackages.harfbuzz
buildPackages.libadwaita
buildPackages.pango
];
cargo = crossCargo; cargo = crossCargo;
blueprint-compiler = crossBlueprint;
}; };
# 2025/01/13: upstreaming is blocked on arrow-cpp, python-pyarrow, python-contourpy, python-matplotlib, python-h5py, python-pandas, google-cloud-cpp # 2025/01/13: upstreaming is blocked on arrow-cpp, python-pyarrow, python-contourpy, python-matplotlib, python-h5py, python-pandas, google-cloud-cpp