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 new file mode 100644 index 000000000000..b74e0abbd515 --- /dev/null +++ b/pkgs/by-name/ca/cargo-auditable/package.nix @@ -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; +} diff --git a/pkgs/development/compilers/rust/1_91.nix b/pkgs/development/compilers/rust/1_91.nix index a5fee800afa4..c9d31d1899d4 100644 --- a/pkgs/development/compilers/rust/1_91.nix +++ b/pkgs/development/compilers/rust/1_91.nix @@ -8,6 +8,11 @@ # Check the version number in the src/llvm-project git submodule in: # https://github.com/rust-lang/rust/blob//.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" ] ) diff --git a/pkgs/development/compilers/rust/cargo-auditable.nix b/pkgs/development/compilers/rust/cargo-auditable.nix deleted file mode 100644 index 2abda28c4d11..000000000000 --- a/pkgs/development/compilers/rust/cargo-auditable.nix +++ /dev/null @@ -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; - }; - } -) diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix index 460c99ef5e17..5324a9f84020 100644 --- a/pkgs/development/compilers/rust/default.nix +++ b/pkgs/development/compilers/rust/default.nix @@ -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 { }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e8f19e0827b0..f144f581b1a4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5203,7 +5203,6 @@ with pkgs; inherit (rustPackages) cargo - cargo-auditable cargo-auditable-cargo-wrapper clippy rustc