mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 07:53:19 +00:00
e1aecec4cd
Previously, cargoUpdateHook was meaningful as it was used in [`cargo-fetch-deps`](19d3cf81d3/pkgs/build-support/rust/fetch-cargo-deps (L71)
). However, this entire file was removed in5f8cf0048e
. As far as I can tell, nothing in the code is using it, but it is still being passed around: https://github.com/NixOS/nixpkgs/search?q=cargoUpdateHook&type=Code&utf8=%E2%9C%93 There are, however, legitimate use cases for it. For example, in some software, some dependencies are not locked in Cargo.toml and this causes Cargo to try fetching another version of them. This doesn't work well with vendoring crates. This hook allows to inject patching or whatever necessary workarounds in the crate vendoring process. I suppose that's what it was for in there in the first place. This patch restores this hook and makes it usable again.
38 lines
901 B
Nix
38 lines
901 B
Nix
{ stdenv, cacert, git, rust, cargo-vendor }:
|
|
{ name ? "cargo-deps", src, srcs, sourceRoot, sha256, cargoUpdateHook ? "" }:
|
|
stdenv.mkDerivation {
|
|
name = "${name}-vendor";
|
|
nativeBuildInputs = [ cacert cargo-vendor git rust.cargo ];
|
|
inherit src srcs sourceRoot;
|
|
|
|
phases = "unpackPhase installPhase";
|
|
|
|
installPhase = ''
|
|
if [[ ! -f Cargo.lock ]]; then
|
|
echo
|
|
echo "ERROR: The Cargo.lock file doesn't exist"
|
|
echo
|
|
echo "Cargo.lock is needed to make sure that cargoSha256 doesn't change"
|
|
echo "when the registry is updated."
|
|
echo
|
|
|
|
exit 1
|
|
fi
|
|
|
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
|
|
|
${cargoUpdateHook}
|
|
|
|
cargo vendor
|
|
|
|
cp -ar vendor $out
|
|
'';
|
|
|
|
outputHashAlgo = "sha256";
|
|
outputHashMode = "recursive";
|
|
outputHash = sha256;
|
|
|
|
impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
|
|
preferLocalBuild = true;
|
|
}
|