2018-02-04 01:09:00 +01:00
|
|
|
{ stdenv, cacert, git, rust, cargo-vendor }:
|
2018-08-20 20:30:02 +02:00
|
|
|
{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "", writeVendorConfig ? false }:
|
2014-10-10 16:59:37 +02:00
|
|
|
stdenv.mkDerivation {
|
2017-08-05 16:38:48 +02:00
|
|
|
name = "${name}-vendor";
|
2018-02-04 01:09:00 +01:00
|
|
|
nativeBuildInputs = [ cacert cargo-vendor git rust.cargo ];
|
2018-08-13 07:44:30 +02:00
|
|
|
inherit src srcs patches sourceRoot;
|
2015-05-29 19:35:31 +02:00
|
|
|
|
2018-08-13 07:44:30 +02:00
|
|
|
phases = "unpackPhase patchPhase installPhase";
|
2015-05-29 19:35:31 +02:00
|
|
|
|
|
|
|
installPhase = ''
|
2017-08-05 16:38:48 +02:00
|
|
|
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
|
2016-02-25 12:05:14 +01:00
|
|
|
|
2017-08-05 16:38:48 +02:00
|
|
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
|
|
|
|
2018-02-23 05:17:03 +01:00
|
|
|
${cargoUpdateHook}
|
|
|
|
|
2018-08-20 20:30:02 +02:00
|
|
|
mkdir -p $out
|
|
|
|
cargo vendor $out > config
|
|
|
|
'' + stdenv.lib.optionalString writeVendorConfig ''
|
|
|
|
mkdir $out/.cargo
|
|
|
|
sed "s|directory = \".*\"|directory = \"./vendor\"|g" config > $out/.cargo/config
|
2015-05-29 19:35:31 +02:00
|
|
|
'';
|
2014-10-10 16:59:37 +02:00
|
|
|
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHash = sha256;
|
|
|
|
|
2016-09-17 21:50:01 +02:00
|
|
|
impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
|
2014-10-10 16:59:37 +02:00
|
|
|
preferLocalBuild = true;
|
|
|
|
}
|