Merge pull request #142154 from figsoda/cargo-hash-default-null
buildRustPackage,fetchCargoTarball: accept empty hashes
This commit is contained in:
commit
5f33ded601
@ -1,17 +1,15 @@
|
|||||||
{ stdenv
|
{ lib
|
||||||
, lib
|
, importCargoLock
|
||||||
, buildPackages
|
, fetchCargoTarball
|
||||||
|
, rust
|
||||||
|
, stdenv
|
||||||
|
, callPackage
|
||||||
, cacert
|
, cacert
|
||||||
|
, git
|
||||||
, cargoBuildHook
|
, cargoBuildHook
|
||||||
, cargoCheckHook
|
, cargoCheckHook
|
||||||
, cargoInstallHook
|
, cargoInstallHook
|
||||||
, cargoSetupHook
|
, cargoSetupHook
|
||||||
, fetchCargoTarball
|
|
||||||
, importCargoLock
|
|
||||||
, rustPlatform
|
|
||||||
, callPackage
|
|
||||||
, git
|
|
||||||
, rust
|
|
||||||
, rustc
|
, rustc
|
||||||
, libiconv
|
, libiconv
|
||||||
, windows
|
, windows
|
||||||
@ -19,12 +17,6 @@
|
|||||||
|
|
||||||
{ name ? "${args.pname}-${args.version}"
|
{ name ? "${args.pname}-${args.version}"
|
||||||
|
|
||||||
# SRI hash
|
|
||||||
, cargoHash ? ""
|
|
||||||
|
|
||||||
# Legacy hash
|
|
||||||
, cargoSha256 ? ""
|
|
||||||
|
|
||||||
# Name for the vendored dependencies tarball
|
# Name for the vendored dependencies tarball
|
||||||
, cargoDepsName ? name
|
, cargoDepsName ? name
|
||||||
|
|
||||||
@ -56,7 +48,7 @@
|
|||||||
, buildAndTestSubdir ? null
|
, buildAndTestSubdir ? null
|
||||||
, ... } @ args:
|
, ... } @ args:
|
||||||
|
|
||||||
assert cargoVendorDir == null && cargoLock == null -> cargoSha256 == "" && cargoHash == ""
|
assert cargoVendorDir == null && cargoLock == null -> !(args ? cargoSha256) && !(args ? cargoHash)
|
||||||
-> throw "cargoSha256, cargoHash, cargoVendorDir, or cargoLock must be set";
|
-> throw "cargoSha256, cargoHash, cargoVendorDir, or cargoLock must be set";
|
||||||
assert buildType == "release" || buildType == "debug";
|
assert buildType == "release" || buildType == "debug";
|
||||||
|
|
||||||
@ -68,15 +60,17 @@ let
|
|||||||
else fetchCargoTarball ({
|
else fetchCargoTarball ({
|
||||||
inherit src srcs sourceRoot unpackPhase cargoUpdateHook;
|
inherit src srcs sourceRoot unpackPhase cargoUpdateHook;
|
||||||
name = cargoDepsName;
|
name = cargoDepsName;
|
||||||
hash = cargoHash;
|
|
||||||
patches = cargoPatches;
|
patches = cargoPatches;
|
||||||
sha256 = cargoSha256;
|
} // lib.optionalAttrs (args ? cargoHash) {
|
||||||
|
hash = args.cargoHash;
|
||||||
|
} // lib.optionalAttrs (args ? cargoSha256) {
|
||||||
|
sha256 = args.cargoSha256;
|
||||||
} // depsExtraArgs)
|
} // depsExtraArgs)
|
||||||
else null;
|
else null;
|
||||||
|
|
||||||
# If we have a cargoSha256 fixed-output derivation, validate it at build time
|
# If we have a cargoSha256 fixed-output derivation, validate it at build time
|
||||||
# against the src fixed-output derivation to check consistency.
|
# against the src fixed-output derivation to check consistency.
|
||||||
validateCargoDeps = !(cargoHash == "" && cargoSha256 == "");
|
validateCargoDeps = args ? cargoHash || args ? cargoSha256;
|
||||||
|
|
||||||
target = rust.toRustTargetSpec stdenv.hostPlatform;
|
target = rust.toRustTargetSpec stdenv.hostPlatform;
|
||||||
targetIsJSON = lib.hasSuffix ".json" target;
|
targetIsJSON = lib.hasSuffix ".json" target;
|
||||||
@ -88,7 +82,7 @@ let
|
|||||||
(lib.removeSuffix ".json" (builtins.baseNameOf "${target}"))
|
(lib.removeSuffix ".json" (builtins.baseNameOf "${target}"))
|
||||||
else target;
|
else target;
|
||||||
|
|
||||||
sysroot = (callPackage ./sysroot {}) {
|
sysroot = callPackage ./sysroot { } {
|
||||||
inherit target shortTarget;
|
inherit target shortTarget;
|
||||||
RUSTFLAGS = args.RUSTFLAGS or "";
|
RUSTFLAGS = args.RUSTFLAGS or "";
|
||||||
originalCargoToml = src + /Cargo.toml; # profile info is later extracted
|
originalCargoToml = src + /Cargo.toml; # profile info is later extracted
|
||||||
|
@ -22,15 +22,13 @@ in
|
|||||||
, srcs ? []
|
, srcs ? []
|
||||||
, patches ? []
|
, patches ? []
|
||||||
, sourceRoot ? ""
|
, sourceRoot ? ""
|
||||||
, hash ? ""
|
|
||||||
, sha256 ? ""
|
|
||||||
, cargoUpdateHook ? ""
|
, cargoUpdateHook ? ""
|
||||||
, ...
|
, ...
|
||||||
} @ args:
|
} @ args:
|
||||||
|
|
||||||
let hash_ =
|
let hash_ =
|
||||||
if hash != "" then { outputHashAlgo = null; outputHash = hash; }
|
if args ? hash then { outputHashAlgo = null; outputHash = args.hash; }
|
||||||
else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; }
|
else if args ? sha256 then { outputHashAlgo = "sha256"; outputHash = args.sha256; }
|
||||||
else throw "fetchCargoTarball requires a hash for ${name}";
|
else throw "fetchCargoTarball requires a hash for ${name}";
|
||||||
in stdenv.mkDerivation ({
|
in stdenv.mkDerivation ({
|
||||||
name = "${name}-vendor.tar.gz";
|
name = "${name}-vendor.tar.gz";
|
||||||
|
Loading…
Reference in New Issue
Block a user