rustPlatform.buildRustPackage: allow specifying cargoDeps
This commit is contained in:
parent
fe94d7da5c
commit
6c4d710b94
@ -38,6 +38,7 @@
|
|||||||
, buildType ? "release"
|
, buildType ? "release"
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
, useFetchCargoVendor ? false
|
, useFetchCargoVendor ? false
|
||||||
|
, cargoDeps ? null
|
||||||
, cargoLock ? null
|
, cargoLock ? null
|
||||||
, cargoVendorDir ? null
|
, cargoVendorDir ? null
|
||||||
, checkType ? buildType
|
, checkType ? buildType
|
||||||
@ -60,14 +61,15 @@
|
|||||||
, buildAndTestSubdir ? null
|
, buildAndTestSubdir ? null
|
||||||
, ... } @ args:
|
, ... } @ args:
|
||||||
|
|
||||||
assert cargoVendorDir == null && cargoLock == null
|
assert cargoVendorDir == null && cargoDeps == null && cargoLock == null
|
||||||
-> !(args ? cargoSha256 && args.cargoSha256 != null) && !(args ? cargoHash && args.cargoHash != null)
|
-> !(args ? cargoSha256 && args.cargoSha256 != null) && !(args ? cargoHash && args.cargoHash != null)
|
||||||
-> throw "cargoHash, cargoVendorDir, or cargoLock must be set";
|
-> throw "cargoHash, cargoVendorDir, cargoDeps, or cargoLock must be set";
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cargoDeps =
|
cargoDeps' =
|
||||||
if cargoVendorDir != null then null
|
if cargoVendorDir != null then null
|
||||||
|
else if cargoDeps != null then cargoDeps
|
||||||
else if cargoLock != null then importCargoLock cargoLock
|
else if cargoLock != null then importCargoLock cargoLock
|
||||||
else if useFetchCargoVendor then (fetchCargoVendor {
|
else if useFetchCargoVendor then (fetchCargoVendor {
|
||||||
inherit src srcs sourceRoot preUnpack unpackPhase postUnpack;
|
inherit src srcs sourceRoot preUnpack unpackPhase postUnpack;
|
||||||
@ -102,7 +104,7 @@ in
|
|||||||
# See https://os.phil-opp.com/testing/ for more information.
|
# See https://os.phil-opp.com/testing/ for more information.
|
||||||
assert useSysroot -> !(args.doCheck or true);
|
assert useSysroot -> !(args.doCheck or true);
|
||||||
|
|
||||||
stdenv.mkDerivation ((removeAttrs args [ "depsExtraArgs" "cargoUpdateHook" "cargoLock" ]) // lib.optionalAttrs useSysroot {
|
stdenv.mkDerivation ((removeAttrs args [ "depsExtraArgs" "cargoUpdateHook" "cargoDeps" "cargoLock" ]) // lib.optionalAttrs useSysroot {
|
||||||
RUSTFLAGS = "--sysroot ${sysroot} " + (args.RUSTFLAGS or "");
|
RUSTFLAGS = "--sysroot ${sysroot} " + (args.RUSTFLAGS or "");
|
||||||
} // lib.optionalAttrs (stdenv.hostPlatform.isDarwin && buildType == "debug") {
|
} // lib.optionalAttrs (stdenv.hostPlatform.isDarwin && buildType == "debug") {
|
||||||
RUSTFLAGS =
|
RUSTFLAGS =
|
||||||
@ -110,7 +112,8 @@ stdenv.mkDerivation ((removeAttrs args [ "depsExtraArgs" "cargoUpdateHook" "carg
|
|||||||
+ lib.optionalString useSysroot "--sysroot ${sysroot} "
|
+ lib.optionalString useSysroot "--sysroot ${sysroot} "
|
||||||
+ (args.RUSTFLAGS or "");
|
+ (args.RUSTFLAGS or "");
|
||||||
} // {
|
} // {
|
||||||
inherit buildAndTestSubdir cargoDeps;
|
cargoDeps = cargoDeps';
|
||||||
|
inherit buildAndTestSubdir;
|
||||||
|
|
||||||
cargoBuildType = buildType;
|
cargoBuildType = buildType;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user