diff options
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/rust/default.nix | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index ff9ca642daad..711276116a66 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -7,6 +7,7 @@ , cargoInstallHook , cargoSetupHook , fetchCargoTarball +, importCargoLock , runCommandNoCC , rustPlatform , callPackage @@ -41,6 +42,7 @@ , cargoDepsHook ? "" , buildType ? "release" , meta ? {} +, cargoLock ? null , cargoVendorDir ? null , checkType ? buildType , depsExtraArgs ? {} @@ -55,19 +57,22 @@ , buildAndTestSubdir ? null , ... } @ args: -assert cargoVendorDir == null -> !(cargoSha256 == "" && cargoHash == ""); +assert cargoVendorDir == null && cargoLock == null -> cargoSha256 == "" && cargoHash == "" + -> throw "cargoSha256, cargoHash, cargoVendorDir, or cargoLock must be set"; assert buildType == "release" || buildType == "debug"; let - cargoDeps = if cargoVendorDir == null - then fetchCargoTarball ({ - inherit src srcs sourceRoot unpackPhase cargoUpdateHook; - name = cargoDepsName; - hash = cargoHash; - patches = cargoPatches; - sha256 = cargoSha256; - } // depsExtraArgs) + cargoDeps = + if cargoVendorDir == null + then if cargoLock != null then importCargoLock cargoLock + else fetchCargoTarball ({ + inherit src srcs sourceRoot unpackPhase cargoUpdateHook; + name = cargoDepsName; + hash = cargoHash; + patches = cargoPatches; + sha256 = cargoSha256; + } // depsExtraArgs) else null; # If we have a cargoSha256 fixed-output derivation, validate it at build time @@ -96,7 +101,7 @@ in # See https://os.phil-opp.com/testing/ for more information. assert useSysroot -> !(args.doCheck or true); -stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // lib.optionalAttrs useSysroot { +stdenv.mkDerivation ((removeAttrs args [ "depsExtraArgs" "cargoLock" ]) // lib.optionalAttrs useSysroot { RUSTFLAGS = "--sysroot ${sysroot} " + (args.RUSTFLAGS or ""); } // { inherit buildAndTestSubdir cargoDeps; |