Skip to content

Commit 6c4d710

Browse files
committed
rustPlatform.buildRustPackage: allow specifying cargoDeps
1 parent fe94d7d commit 6c4d710

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkgs/build-support/rust/build-rust-package/default.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
, buildType ? "release"
3939
, meta ? {}
4040
, useFetchCargoVendor ? false
41+
, cargoDeps ? null
4142
, cargoLock ? null
4243
, cargoVendorDir ? null
4344
, checkType ? buildType
@@ -60,14 +61,15 @@
6061
, buildAndTestSubdir ? null
6162
, ... } @ args:
6263

63-
assert cargoVendorDir == null && cargoLock == null
64+
assert cargoVendorDir == null && cargoDeps == null && cargoLock == null
6465
-> !(args ? cargoSha256 && args.cargoSha256 != null) && !(args ? cargoHash && args.cargoHash != null)
65-
-> throw "cargoHash, cargoVendorDir, or cargoLock must be set";
66+
-> throw "cargoHash, cargoVendorDir, cargoDeps, or cargoLock must be set";
6667

6768
let
6869

69-
cargoDeps =
70+
cargoDeps' =
7071
if cargoVendorDir != null then null
72+
else if cargoDeps != null then cargoDeps
7173
else if cargoLock != null then importCargoLock cargoLock
7274
else if useFetchCargoVendor then (fetchCargoVendor {
7375
inherit src srcs sourceRoot preUnpack unpackPhase postUnpack;
@@ -102,15 +104,16 @@ in
102104
# See https://os.phil-opp.com/testing/ for more information.
103105
assert useSysroot -> !(args.doCheck or true);
104106

105-
stdenv.mkDerivation ((removeAttrs args [ "depsExtraArgs" "cargoUpdateHook" "cargoLock" ]) // lib.optionalAttrs useSysroot {
107+
stdenv.mkDerivation ((removeAttrs args [ "depsExtraArgs" "cargoUpdateHook" "cargoDeps" "cargoLock" ]) // lib.optionalAttrs useSysroot {
106108
RUSTFLAGS = "--sysroot ${sysroot} " + (args.RUSTFLAGS or "");
107109
} // lib.optionalAttrs (stdenv.hostPlatform.isDarwin && buildType == "debug") {
108110
RUSTFLAGS =
109111
"-C split-debuginfo=packed "
110112
+ lib.optionalString useSysroot "--sysroot ${sysroot} "
111113
+ (args.RUSTFLAGS or "");
112114
} // {
113-
inherit buildAndTestSubdir cargoDeps;
115+
cargoDeps = cargoDeps';
116+
inherit buildAndTestSubdir;
114117

115118
cargoBuildType = buildType;
116119

0 commit comments

Comments
 (0)