From 758ae7d4f44e7d0544f4b57debdbd1d385c9ea3e Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 22 Apr 2023 12:46:32 -0700 Subject: [PATCH 1/3] cargo-auditable: mark broken if cross --- pkgs/development/compilers/rust/cargo-auditable.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/rust/cargo-auditable.nix b/pkgs/development/compilers/rust/cargo-auditable.nix index 34549e1982ed..49968cc899ba 100644 --- a/pkgs/development/compilers/rust/cargo-auditable.nix +++ b/pkgs/development/compilers/rust/cargo-auditable.nix @@ -1,4 +1,6 @@ -{ lib, fetchFromGitHub, makeRustPlatform, rustc, cargo, installShellFiles }: +{ lib +, stdenv +, fetchFromGitHub, makeRustPlatform, rustc, cargo, installShellFiles }: let args = rec { @@ -25,6 +27,7 @@ let changelog = "https://github.com/rust-secure-code/cargo-auditable/blob/v${version}/cargo-auditable/CHANGELOG.md"; license = with licenses; [ mit /* or */ asl20 ]; maintainers = with maintainers; [ figsoda ]; + broken = stdenv.hostPlatform != stdenv.buildPlatform; }; }; From ad3a53265807daf53c1e64482ad710a93fe8f1ce Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 22 Apr 2023 12:52:06 -0700 Subject: [PATCH 2/3] rust/cargo.nix: disable audit if audit.meta.broken Not much point in auditing things that can't be built. --- pkgs/development/compilers/rust/cargo.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/rust/cargo.nix b/pkgs/development/compilers/rust/cargo.nix index 7c094ac4ef9c..705d172e4fcf 100644 --- a/pkgs/development/compilers/rust/cargo.nix +++ b/pkgs/development/compilers/rust/cargo.nix @@ -2,13 +2,13 @@ , file, curl, pkg-config, python3, openssl, cmake, zlib , installShellFiles, makeWrapper, rustPlatform, rustc , CoreFoundation, Security -, auditable ? true +, auditable ? !cargo-auditable.meta.broken , cargo-auditable }: -rustPlatform.buildRustPackage.override { +rustPlatform.buildRustPackage.override (lib.optionalAttrs (!cargo-auditable.meta.broken) { cargo-auditable = cargo-auditable.bootstrap; -} { +}) { pname = "cargo"; inherit (rustc) version src; From 0ac955ad63e2f94c64de584551493ceb33b00b45 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 22 Apr 2023 12:53:23 -0700 Subject: [PATCH 3/3] 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 --- pkgs/development/compilers/rust/cargo-auditable.nix | 4 +--- pkgs/development/compilers/rust/cargo.nix | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/rust/cargo-auditable.nix b/pkgs/development/compilers/rust/cargo-auditable.nix index 49968cc899ba..dbbfff4dc6b6 100644 --- a/pkgs/development/compilers/rust/cargo-auditable.nix +++ b/pkgs/development/compilers/rust/cargo-auditable.nix @@ -1,6 +1,4 @@ -{ lib -, stdenv -, fetchFromGitHub, makeRustPlatform, rustc, cargo, installShellFiles }: +{ lib, fetchFromGitHub, makeRustPlatform, rustc, cargo, installShellFiles, stdenv }: let args = rec { diff --git a/pkgs/development/compilers/rust/cargo.nix b/pkgs/development/compilers/rust/cargo.nix index 705d172e4fcf..beb1912658cc 100644 --- a/pkgs/development/compilers/rust/cargo.nix +++ b/pkgs/development/compilers/rust/cargo.nix @@ -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"; +})