From 2e71e06c0583d84d6119d42f1ea4f4cf307701b6 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 27 Aug 2025 18:43:49 +0000 Subject: [PATCH] lemoa: inline the cross compilation fix --- overlays/cross.nix | 108 ++++++++++++++++----------------- pkgs/by-name/lemoa/package.nix | 8 +++ 2 files changed, 62 insertions(+), 54 deletions(-) diff --git a/overlays/cross.nix b/overlays/cross.nix index 8200766f2..ecee732d7 100644 --- a/overlays/cross.nix +++ b/overlays/cross.nix @@ -52,63 +52,63 @@ let 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 - crossCargo = let - inherit (final.pkgsBuildHost) cargo; - inherit (final.rust.envVars) setEnv rustHostPlatformSpec; - in (final.pkgsBuildBuild.writeShellScriptBin "cargo" '' - targetDir=target - isFlavored= - outDir= - profile= + # crossCargo = let + # inherit (final.pkgsBuildHost) cargo; + # inherit (final.rust.envVars) setEnv rustHostPlatformSpec; + # in (final.pkgsBuildBuild.writeShellScriptBin "cargo" '' + # targetDir=target + # isFlavored= + # outDir= + # profile= - cargoArgs=("$@") - nextIsOutDir= - nextIsProfile= - nextIsTargetDir= - for arg in "''${cargoArgs[@]}"; do - if [[ -n "$nextIsOutDir" ]]; then - nextIsOutDir= - outDir="$arg" - elif [[ -n "$nextIsProfile" ]]; then - nextIsProfile= - profile="$arg" - elif [[ -n "$nextIsTargetDir" ]]; then - nextIsTargetDir= - targetDir="$arg" - elif [[ "$arg" = "build" ]]; then - isFlavored=1 - elif [[ "$arg" = "--out-dir" ]]; then - nextIsOutDir=1 - elif [[ "$arg" = "--profile" ]]; then - nextIsProfile=1 - elif [[ "$arg" = "--release" ]]; then - profile=release - elif [[ "$arg" = "--target-dir" ]]; then - nextIsTargetDir=1 - fi - done + # cargoArgs=("$@") + # nextIsOutDir= + # nextIsProfile= + # nextIsTargetDir= + # for arg in "''${cargoArgs[@]}"; do + # if [[ -n "$nextIsOutDir" ]]; then + # nextIsOutDir= + # outDir="$arg" + # elif [[ -n "$nextIsProfile" ]]; then + # nextIsProfile= + # profile="$arg" + # elif [[ -n "$nextIsTargetDir" ]]; then + # nextIsTargetDir= + # targetDir="$arg" + # elif [[ "$arg" = "build" ]]; then + # isFlavored=1 + # elif [[ "$arg" = "--out-dir" ]]; then + # nextIsOutDir=1 + # elif [[ "$arg" = "--profile" ]]; then + # nextIsProfile=1 + # elif [[ "$arg" = "--release" ]]; then + # profile=release + # elif [[ "$arg" = "--target-dir" ]]; then + # nextIsTargetDir=1 + # fi + # done - extraFlags=() + # extraFlags=() - # not all subcommands support flavored arguments like `--target` - if [ -n "$isFlavored" ]; then - # 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: - extraFlags+=( - --target "${rustHostPlatformSpec}" - -Z unstable-options - ) - if [ -z "$outDir" ]; then - extraFlags+=( - --out-dir "$targetDir"/''${profile:-debug} - ) - fi - fi + # # not all subcommands support flavored arguments like `--target` + # if [ -n "$isFlavored" ]; then + # # 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: + # extraFlags+=( + # --target "${rustHostPlatformSpec}" + # -Z unstable-options + # ) + # if [ -z "$outDir" ]; then + # extraFlags+=( + # --out-dir "$targetDir"/''${profile:-debug} + # ) + # fi + # fi - exec ${setEnv} "${lib.getExe cargo}" "$@" "''${extraFlags[@]}" - '').overrideAttrs { - inherit (cargo) meta; - }; + # exec ${setEnv} "${lib.getExe cargo}" "$@" "''${extraFlags[@]}" + # '').overrideAttrs { + # inherit (cargo) meta; + # }; in with final; { # binutils = prev.binutils.override { # # 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: { # # 2025/07/27: upstreaming is blocked on qtsvg diff --git a/pkgs/by-name/lemoa/package.nix b/pkgs/by-name/lemoa/package.nix index da622cbbb..26a908821 100644 --- a/pkgs/by-name/lemoa/package.nix +++ b/pkgs/by-name/lemoa/package.nix @@ -33,6 +33,12 @@ stdenv.mkDerivation rec { 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 = [ cargo desktop-file-utils @@ -49,6 +55,8 @@ stdenv.mkDerivation rec { openssl ]; + env.CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec; + passthru.updateScript = gitUpdater { rev-prefix = "v"; };