rust/cargo.nix: set HOST_PKG_CONFIG_PATH for cross builds

Prior to this commit, builds of
`pkgsCross.aarch64-multiplatform.cargo` would fail due to being
unable to find `-lz` when compiling cargo's own `build.rs` for the
`buildPlatform`.

This environment variable uses the (very confusing) LLVM convention
of calling the buildPlatform "HOST".

Co-authored-by: figsoda <figsoda@pm.me>
This commit is contained in:
Adam Joseph 2023-04-22 12:53:23 -07:00
parent ad3a532658
commit 0ac955ad63
2 changed files with 8 additions and 6 deletions

View file

@ -1,6 +1,4 @@
{ lib
, stdenv
, fetchFromGitHub, makeRustPlatform, rustc, cargo, installShellFiles }:
{ lib, fetchFromGitHub, makeRustPlatform, rustc, cargo, installShellFiles, stdenv }:
let
args = rec {

View file

@ -1,14 +1,15 @@
{ lib, stdenv, pkgsBuildHost, pkgsHostHost
, file, curl, pkg-config, python3, openssl, cmake, zlib
, installShellFiles, makeWrapper, rustPlatform, rustc
, installShellFiles, makeWrapper, rustPlatform, rust, rustc
, CoreFoundation, Security
, auditable ? !cargo-auditable.meta.broken
, cargo-auditable
, pkgsBuildBuild
}:
rustPlatform.buildRustPackage.override (lib.optionalAttrs (!cargo-auditable.meta.broken) {
rustPlatform.buildRustPackage.override {
cargo-auditable = cargo-auditable.bootstrap;
}) {
} ({
pname = "cargo";
inherit (rustc) version src;
@ -113,3 +114,6 @@ rustPlatform.buildRustPackage.override (lib.optionalAttrs (!cargo-auditable.meta
platforms = platforms.unix;
};
}
// lib.optionalAttrs (rust.toRustTarget stdenv.buildPlatform != rust.toRustTarget stdenv.hostPlatform) {
HOST_PKG_CONFIG_PATH="${pkgsBuildBuild.pkg-config}/bin/pkg-config";
})