From 7243e1b6657f0713809facaa5c3246fe2d336a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Thu, 12 Sep 2024 11:58:27 +0200 Subject: [PATCH] buildRustPackage: allow passing in cargoDeps This is useful when constructing overlays and trying to copy a buildRustPackage from a different package --- .../rust/build-rust-package/default.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/rust/build-rust-package/default.nix b/pkgs/build-support/rust/build-rust-package/default.nix index 40b7a61812328..937c45322b957 100644 --- a/pkgs/build-support/rust/build-rust-package/default.nix +++ b/pkgs/build-support/rust/build-rust-package/default.nix @@ -36,6 +36,7 @@ , cargoDepsHook ? "" , buildType ? "release" , meta ? {} +, cargoDeps ? null , cargoLock ? null , cargoVendorDir ? null , checkType ? buildType @@ -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; @@ -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;