Skip to content

Commit

Permalink
buildRustPackage: allow passing in cargoDeps
Browse files Browse the repository at this point in the history
This is useful when constructing overlays and trying to copy a
buildRustPackage from a different package
  • Loading branch information
SuperSandro2000 committed Sep 12, 2024
1 parent 6ae34b4 commit 7243e1b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkgs/build-support/rust/build-rust-package/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
, cargoDepsHook ? ""
, buildType ? "release"
, meta ? {}
, cargoDeps ? null
, cargoLock ? null
, cargoVendorDir ? null
, checkType ? buildType
Expand All @@ -59,14 +60,15 @@
, buildAndTestSubdir ? null
, ... } @ args:

assert cargoVendorDir == null && cargoLock == null
assert cargoVendorDir == null && cargoLock == null && cargoDeps == null
-> !(args ? cargoSha256 && args.cargoSha256 != null) && !(args ? cargoHash && args.cargoHash != null)
-> throw "cargoHash, cargoVendorDir, or cargoLock must be set";

let

cargoDeps =
if cargoVendorDir != null then null
cargoDeps' =
if cargoDeps != null then cargoDeps
else if cargoVendorDir != null then null
else if cargoLock != null then importCargoLock cargoLock
else fetchCargoTarball ({
inherit src srcs sourceRoot preUnpack unpackPhase postUnpack cargoUpdateHook;
Expand Down Expand Up @@ -98,7 +100,9 @@ assert useSysroot -> !(args.doCheck or true);
stdenv.mkDerivation ((removeAttrs args [ "depsExtraArgs" "cargoUpdateHook" "cargoLock" ]) // lib.optionalAttrs useSysroot {
RUSTFLAGS = "--sysroot ${sysroot} " + (args.RUSTFLAGS or "");
} // {
inherit buildAndTestSubdir cargoDeps;
inherit buildAndTestSubdir;

cargoDeps = cargoDeps';

cargoBuildType = buildType;

Expand Down

0 comments on commit 7243e1b

Please sign in to comment.