Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildRustPackage: allow passing in cargoDeps #340798

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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