From 78cab60536fc803cd2aecf6df1d54dfb99af3e76 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Mon, 24 Nov 2025 13:37:52 -0500 Subject: [PATCH] cargo-auditable: Move builder to seperate file --- pkgs/by-name/ca/cargo-auditable/builder.nix | 63 ++++++++++++++++++ pkgs/by-name/ca/cargo-auditable/package.nix | 74 ++++----------------- 2 files changed, 75 insertions(+), 62 deletions(-) create mode 100644 pkgs/by-name/ca/cargo-auditable/builder.nix diff --git a/pkgs/by-name/ca/cargo-auditable/builder.nix b/pkgs/by-name/ca/cargo-auditable/builder.nix new file mode 100644 index 000000000000..348ff29ef61a --- /dev/null +++ b/pkgs/by-name/ca/cargo-auditable/builder.nix @@ -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; + }; + }; +} diff --git a/pkgs/by-name/ca/cargo-auditable/package.nix b/pkgs/by-name/ca/cargo-auditable/package.nix index cd1ca12f3a9b..7e8e4e0810d4 100644 --- a/pkgs/by-name/ca/cargo-auditable/package.nix +++ b/pkgs/by-name/ca/cargo-auditable/package.nix @@ -1,13 +1,11 @@ { - lib, buildPackages, - fetchFromGitHub, + callPackage, makeRustPlatform, - installShellFiles, - stdenv, }: - 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 { @@ -15,71 +13,23 @@ let }; }; - auditableBuilder = lib.extendMkDerivation { - constructDrv = rustPlatform.buildRustPackage.override { cargo-auditable = bootstrap; }; - - extendDrvArgs = - finalAttrs: - { - pname ? "cargo-auditable", - auditable ? true, - ... - }: - { - inherit auditable pname; - version = "0.6.5"; - - src = fetchFromGitHub { - owner = "rust-secure-code"; - repo = "cargo-auditable"; - tag = "v${finalAttrs.version}"; - hash = "sha256-zjv2/qZM0vRyz45DeKRtPHaamv2iLtjpSedVTEXeDr8="; - }; - - cargoHash = "sha256-oTPGmoGlNfPVZ6qha/oXyPJp94fT2cNlVggbIGHf2bc="; - - 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 = { - inherit 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; - }; - }; + auditableBuilder = callPackage ./builder.nix { + inherit rustPlatform; + auditable-bootstrap = bootstrap; }; + hash = "sha256-zjv2/qZM0vRyz45DeKRtPHaamv2iLtjpSedVTEXeDr8="; + cargoHash = "sha256-oTPGmoGlNfPVZ6qha/oXyPJp94fT2cNlVggbIGHf2bc="; + version = "0.6.5"; + # 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; }