diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2021-10-20 06:01:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-20 06:01:15 +0000 |
commit | 2d8f645c7980a3cfa55fe2b1402f7682bbd3fdc9 (patch) | |
tree | 47c1a2ab1f34829cd39b97d2d38f7774061495b1 /pkgs/build-support/rust | |
parent | bca988659f50986b1387e7a42e3db3ed86f19995 (diff) | |
parent | a9b7ae8883026a5f613a3813c3625a14eb376726 (diff) | |
download | nixpkgs-2d8f645c7980a3cfa55fe2b1402f7682bbd3fdc9.tar nixpkgs-2d8f645c7980a3cfa55fe2b1402f7682bbd3fdc9.tar.gz nixpkgs-2d8f645c7980a3cfa55fe2b1402f7682bbd3fdc9.tar.bz2 nixpkgs-2d8f645c7980a3cfa55fe2b1402f7682bbd3fdc9.tar.lz nixpkgs-2d8f645c7980a3cfa55fe2b1402f7682bbd3fdc9.tar.xz nixpkgs-2d8f645c7980a3cfa55fe2b1402f7682bbd3fdc9.tar.zst nixpkgs-2d8f645c7980a3cfa55fe2b1402f7682bbd3fdc9.zip |
Merge master into staging-next
Diffstat (limited to 'pkgs/build-support/rust')
-rw-r--r-- | pkgs/build-support/rust/default.nix | 34 | ||||
-rw-r--r-- | pkgs/build-support/rust/fetchCargoTarball.nix | 6 |
2 files changed, 16 insertions, 24 deletions
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 2eb45bcafa1..3d7057dd7d9 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -1,17 +1,15 @@ -{ stdenv -, lib -, buildPackages +{ lib +, importCargoLock +, fetchCargoTarball +, rust +, stdenv +, callPackage , cacert +, git , cargoBuildHook , cargoCheckHook , cargoInstallHook , cargoSetupHook -, fetchCargoTarball -, importCargoLock -, rustPlatform -, callPackage -, git -, rust , rustc , libiconv , windows @@ -19,12 +17,6 @@ { name ? "${args.pname}-${args.version}" - # SRI hash -, cargoHash ? "" - - # Legacy hash -, cargoSha256 ? "" - # Name for the vendored dependencies tarball , cargoDepsName ? name @@ -56,7 +48,7 @@ , buildAndTestSubdir ? null , ... } @ 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"; assert buildType == "release" || buildType == "debug"; @@ -68,15 +60,17 @@ let else fetchCargoTarball ({ inherit src srcs sourceRoot unpackPhase cargoUpdateHook; name = cargoDepsName; - hash = cargoHash; patches = cargoPatches; - sha256 = cargoSha256; + } // lib.optionalAttrs (args ? cargoHash) { + hash = args.cargoHash; + } // lib.optionalAttrs (args ? cargoSha256) { + sha256 = args.cargoSha256; } // depsExtraArgs) else null; # If we have a cargoSha256 fixed-output derivation, validate it at build time # against the src fixed-output derivation to check consistency. - validateCargoDeps = !(cargoHash == "" && cargoSha256 == ""); + validateCargoDeps = args ? cargoHash || args ? cargoSha256; target = rust.toRustTargetSpec stdenv.hostPlatform; targetIsJSON = lib.hasSuffix ".json" target; @@ -88,7 +82,7 @@ let (lib.removeSuffix ".json" (builtins.baseNameOf "${target}")) else target; - sysroot = (callPackage ./sysroot {}) { + sysroot = callPackage ./sysroot { } { inherit target shortTarget; RUSTFLAGS = args.RUSTFLAGS or ""; originalCargoToml = src + /Cargo.toml; # profile info is later extracted diff --git a/pkgs/build-support/rust/fetchCargoTarball.nix b/pkgs/build-support/rust/fetchCargoTarball.nix index 2e8830b4757..c2be9aac82d 100644 --- a/pkgs/build-support/rust/fetchCargoTarball.nix +++ b/pkgs/build-support/rust/fetchCargoTarball.nix @@ -22,15 +22,13 @@ in , srcs ? [] , patches ? [] , sourceRoot ? "" -, hash ? "" -, sha256 ? "" , cargoUpdateHook ? "" , ... } @ args: let hash_ = - if hash != "" then { outputHashAlgo = null; outputHash = hash; } - else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; } + if args ? hash then { outputHashAlgo = null; outputHash = args.hash; } + else if args ? sha256 then { outputHashAlgo = "sha256"; outputHash = args.sha256; } else throw "fetchCargoTarball requires a hash for ${name}"; in stdenv.mkDerivation ({ name = "${name}-vendor.tar.gz"; |