Skip to content

Commit

Permalink
Merge pull request #115 from thillux/small-fixes
Browse files Browse the repository at this point in the history
passthru-vendored: use features and target for rust derivations
  • Loading branch information
nikstur authored Jul 15, 2024
2 parents f66a5a1 + e9a664f commit 21d203a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions nix/passthru-vendored.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@
# This could be done much more elegantly if `buildRustPackage` supported
# finalAttrs. When https://github.com/NixOS/nixpkgs/pull/194475 lands, we can
# most likely get rid of this.
rust = package: { cargo-cyclonedx }: package.overrideAttrs
rust = package: { cargo-cyclonedx, lib, stdenv }: package.overrideAttrs
(previousAttrs: {
passthru = (previousAttrs.passthru or { }) // {
bombonVendoredSbom = package.overrideAttrs (previousAttrs: {
nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [ cargo-cyclonedx ];
outputs = [ "out" ];
phases = [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" "installPhase" ];
buildPhase = ''
cargo cyclonedx --spec-version 1.4 --format json
'';
cargo cyclonedx --spec-version 1.4 --format json --target ${stdenv.hostPlatform.rust.rustcTarget}
''
+ lib.optionalString
(builtins.hasAttr "buildNoDefaultFeatures" previousAttrs)
" --no-default-features"
+ lib.optionalString
(builtins.hasAttr "buildFeatures" previousAttrs)
(" --features " + builtins.concatStringsSep "," previousAttrs.buildFeatures)
;
installPhase = ''
mkdir -p $out
find . -name "*.cdx.json" -execdir install {} $out/{} \;
Expand All @@ -24,5 +31,4 @@
});
};
});

}

0 comments on commit 21d203a

Please sign in to comment.