cargo-auditable: Refactor & clean-up, to by-name, 0.6.5 -> 0.7.2 (#464651)

This commit is contained in:
Wolfgang Walther
2025-12-11 17:24:54 +00:00
committed by GitHub
6 changed files with 108 additions and 79 deletions
@@ -0,0 +1,63 @@
{
lib,
stdenv,
rustPlatform,
fetchFromGitHub,
installShellFiles,
auditable-bootstrap,
}:
lib.extendMkDerivation {
constructDrv = rustPlatform.buildRustPackage.override { cargo-auditable = auditable-bootstrap; };
extendDrvArgs =
finalAttrs:
{
pname ? "cargo-auditable",
auditable ? true,
hash ? "",
cargoHash ? "",
...
}:
{
inherit auditable pname;
src = fetchFromGitHub {
owner = "rust-secure-code";
repo = "cargo-auditable";
tag = "v${finalAttrs.version}";
inherit hash;
};
nativeBuildInputs = [
installShellFiles
];
checkFlags = [
# requires wasm32-unknown-unknown target
"--skip=test_wasm"
# Seems to be a bug in tests of locked vs. semver compatible packages
# https://github.com/rust-secure-code/cargo-auditable/issues/235
"--skip=test_proc_macro"
"--skip=test_self_hosting"
];
postInstall = ''
installManPage cargo-auditable/cargo-auditable.1
'';
passthru.bootstrap = auditable-bootstrap;
meta = {
description = "Tool to make production Rust binaries auditable";
mainProgram = "cargo-auditable";
homepage = "https://github.com/rust-secure-code/cargo-auditable";
changelog = "https://github.com/rust-secure-code/cargo-auditable/blob/v${finalAttrs.version}/cargo-auditable/CHANGELOG.md";
license = with lib.licenses; [
mit # or
asl20
];
maintainers = with lib.maintainers; [ RossSmyth ];
broken = stdenv.hostPlatform != stdenv.buildPlatform;
};
};
}
@@ -0,0 +1,35 @@
{
buildPackages,
callPackage,
makeRustPlatform,
}:
let
# Need to use the build platform rustc and Cargo so that
# we don't infrec
rustPlatform = makeRustPlatform {
inherit (buildPackages) rustc;
cargo = buildPackages.cargo.override {
auditable = false;
};
};
auditableBuilder = callPackage ./builder.nix {
inherit rustPlatform;
auditable-bootstrap = bootstrap;
};
version = "0.7.2";
hash = "sha256-hR6PjTOps8JSM7UbfGlCoZmmwtWExVqYwh4lxDiFWdc=";
cargoHash = "sha256-JEfnUJ9J6Xak3AOCwQCnu+v+3Wl3QbXX20qVFWB6040=";
# cargo-auditable cannot be built with cargo-auditable until cargo-auditable is built
bootstrap = auditableBuilder {
inherit version hash cargoHash;
pname = "cargo-auditable-bootstrap";
auditable = false;
};
in
auditableBuilder {
inherit version hash cargoHash;
auditable = true;
}
+8 -1
View File
@@ -8,6 +8,11 @@
# Check the version number in the src/llvm-project git submodule in:
# https://github.com/rust-lang/rust/blob/<version-tag>/.gitmodules
# Note: The way this is structured is:
# 1. Import default.nix, and apply arguments as needed for the file-defined function
# 2. Implicitly, all arguments to this file are applied to the function that is imported.
# if you want to add an argument to default.nix's top-level function, but not the function
# it instantiates, add it to the `removeAttrs` call below.
{
stdenv,
lib,
@@ -22,6 +27,7 @@
wrapRustcWith,
llvmPackages,
llvm,
cargo-auditable,
wrapCCWith,
overrideCC,
fetchpatch,
@@ -51,7 +57,7 @@ import ./default.nix
llvmSharedForHost = llvmSharedFor pkgsBuildHost;
llvmSharedForTarget = llvmSharedFor pkgsBuildTarget;
inherit llvmPackages;
inherit llvmPackages cargo-auditable;
# For use at runtime
llvmShared = llvmSharedFor pkgsHostTarget;
@@ -93,5 +99,6 @@ import ./default.nix
"overrideCC"
"pkgsHostTarget"
"fetchpatch"
"cargo-auditable"
]
)
@@ -1,76 +0,0 @@
{
lib,
buildPackages,
fetchFromGitHub,
makeRustPlatform,
installShellFiles,
stdenv,
}:
let
args = rec {
pname = "cargo-auditable";
version = "0.6.5";
src = fetchFromGitHub {
owner = "rust-secure-code";
repo = "cargo-auditable";
rev = "v${version}";
sha256 = "sha256-zjv2/qZM0vRyz45DeKRtPHaamv2iLtjpSedVTEXeDr8=";
};
cargoDeps = rustPlatform.fetchCargoVendor {
inherit pname version src;
hash = "sha256-oTPGmoGlNfPVZ6qha/oXyPJp94fT2cNlVggbIGHf2bc=";
};
checkFlags = [
# requires wasm32-unknown-unknown target
"--skip=test_wasm"
];
meta = {
description = "Tool to make production Rust binaries auditable";
mainProgram = "cargo-auditable";
homepage = "https://github.com/rust-secure-code/cargo-auditable";
changelog = "https://github.com/rust-secure-code/cargo-auditable/blob/v${version}/cargo-auditable/CHANGELOG.md";
license = with lib.licenses; [
mit # or
asl20
];
maintainers = with lib.maintainers; [ RossSmyth ];
broken = stdenv.hostPlatform != stdenv.buildPlatform;
};
};
rustPlatform = makeRustPlatform {
inherit (buildPackages) rustc;
cargo = buildPackages.cargo.override {
auditable = false;
};
};
bootstrap = rustPlatform.buildRustPackage (
args
// {
auditable = false;
}
);
in
rustPlatform.buildRustPackage.override { cargo-auditable = bootstrap; } (
args
// {
nativeBuildInputs = [
installShellFiles
];
postInstall = ''
installManPage cargo-auditable/cargo-auditable.1
'';
passthru = {
inherit bootstrap;
};
}
)
+2 -1
View File
@@ -11,6 +11,7 @@
llvmSharedForHost,
llvmSharedForTarget,
llvmPackages, # Exposed through rustc for LTO in Firefox
cargo-auditable,
}:
{
stdenv,
@@ -125,7 +126,7 @@ in
}
else
self.callPackage ./cargo_cross.nix { };
cargo-auditable = self.callPackage ./cargo-auditable.nix { };
inherit cargo-auditable;
cargo-auditable-cargo-wrapper = self.callPackage ./cargo-auditable-cargo-wrapper.nix { };
clippy-unwrapped = self.callPackage ./clippy.nix { };
clippy = if !fastCross then self.clippy-unwrapped else self.callPackage ./clippy-wrapper.nix { };
-1
View File
@@ -5203,7 +5203,6 @@ with pkgs;
inherit (rustPackages)
cargo
cargo-auditable
cargo-auditable-cargo-wrapper
clippy
rustc