lemoa: inline the cross compilation fix

This commit is contained in:
2025-08-27 18:43:49 +00:00
parent 203832b5a8
commit 2e71e06c05
2 changed files with 62 additions and 54 deletions

View File

@@ -52,63 +52,63 @@ let
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);
# `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;
inherit (final.rust.envVars) setEnv rustHostPlatformSpec; # inherit (final.rust.envVars) setEnv rustHostPlatformSpec;
in (final.pkgsBuildBuild.writeShellScriptBin "cargo" '' # in (final.pkgsBuildBuild.writeShellScriptBin "cargo" ''
targetDir=target # targetDir=target
isFlavored= # isFlavored=
outDir= # outDir=
profile= # profile=
cargoArgs=("$@") # cargoArgs=("$@")
nextIsOutDir= # nextIsOutDir=
nextIsProfile= # nextIsProfile=
nextIsTargetDir= # nextIsTargetDir=
for arg in "''${cargoArgs[@]}"; do # for arg in "''${cargoArgs[@]}"; do
if [[ -n "$nextIsOutDir" ]]; then # if [[ -n "$nextIsOutDir" ]]; then
nextIsOutDir= # nextIsOutDir=
outDir="$arg" # outDir="$arg"
elif [[ -n "$nextIsProfile" ]]; then # elif [[ -n "$nextIsProfile" ]]; then
nextIsProfile= # nextIsProfile=
profile="$arg" # profile="$arg"
elif [[ -n "$nextIsTargetDir" ]]; then # elif [[ -n "$nextIsTargetDir" ]]; then
nextIsTargetDir= # nextIsTargetDir=
targetDir="$arg" # targetDir="$arg"
elif [[ "$arg" = "build" ]]; then # elif [[ "$arg" = "build" ]]; then
isFlavored=1 # isFlavored=1
elif [[ "$arg" = "--out-dir" ]]; then # elif [[ "$arg" = "--out-dir" ]]; then
nextIsOutDir=1 # nextIsOutDir=1
elif [[ "$arg" = "--profile" ]]; then # elif [[ "$arg" = "--profile" ]]; then
nextIsProfile=1 # nextIsProfile=1
elif [[ "$arg" = "--release" ]]; then # elif [[ "$arg" = "--release" ]]; then
profile=release # profile=release
elif [[ "$arg" = "--target-dir" ]]; then # elif [[ "$arg" = "--target-dir" ]]; then
nextIsTargetDir=1 # nextIsTargetDir=1
fi # fi
done # done
extraFlags=() # extraFlags=()
# not all subcommands support flavored arguments like `--target` # # not all subcommands support flavored arguments like `--target`
if [ -n "$isFlavored" ]; then # if [ -n "$isFlavored" ]; then
# pass the target triple to cargo so it will cross compile # # pass the target triple to cargo so it will cross compile
# and fix so it places outputs in the same directory as non-cross, see: <https://doc.rust-lang.org/cargo/guide/build-cache.html> # # and fix so it places outputs in the same directory as non-cross, see: <https://doc.rust-lang.org/cargo/guide/build-cache.html>
extraFlags+=( # extraFlags+=(
--target "${rustHostPlatformSpec}" # --target "${rustHostPlatformSpec}"
-Z unstable-options # -Z unstable-options
) # )
if [ -z "$outDir" ]; then # if [ -z "$outDir" ]; then
extraFlags+=( # extraFlags+=(
--out-dir "$targetDir"/''${profile:-debug} # --out-dir "$targetDir"/''${profile:-debug}
) # )
fi # fi
fi # fi
exec ${setEnv} "${lib.getExe cargo}" "$@" "''${extraFlags[@]}" # exec ${setEnv} "${lib.getExe cargo}" "$@" "''${extraFlags[@]}"
'').overrideAttrs { # '').overrideAttrs {
inherit (cargo) meta; # inherit (cargo) meta;
}; # };
in with final; { in with final; {
# binutils = prev.binutils.override { # binutils = prev.binutils.override {
# # fix that resulting binary files would specify build #!sh as their interpreter. # # fix that resulting binary files would specify build #!sh as their interpreter.
@@ -295,7 +295,7 @@ in with final; {
# ]; # ];
# }); # });
lemoa = prev.lemoa.override { cargo = crossCargo; }; # lemoa = prev.lemoa.override { cargo = crossCargo; };
# libsForQt5 = prev.libsForQt5.overrideScope (self: super: { # libsForQt5 = prev.libsForQt5.overrideScope (self: super: {
# # 2025/07/27: upstreaming is blocked on qtsvg # # 2025/07/27: upstreaming is blocked on qtsvg

View File

@@ -33,6 +33,12 @@ stdenv.mkDerivation rec {
hash = "sha256-ALoxT+RLL4omJ7quWDJVdXgevaO8i8q/29FFFudIRV4="; hash = "sha256-ALoxT+RLL4omJ7quWDJVdXgevaO8i8q/29FFFudIRV4=";
}; };
postPatch = ''
substituteInPlace src/meson.build --replace-fail \
"'target' / rust_target / meson.project_name()" \
"'target' / '${stdenv.hostPlatform.rust.cargoShortTarget}' / rust_target / meson.project_name()"
'';
nativeBuildInputs = [ nativeBuildInputs = [
cargo cargo
desktop-file-utils desktop-file-utils
@@ -49,6 +55,8 @@ stdenv.mkDerivation rec {
openssl openssl
]; ];
env.CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec;
passthru.updateScript = gitUpdater { passthru.updateScript = gitUpdater {
rev-prefix = "v"; rev-prefix = "v";
}; };