2018-11-21 12:38:49 +00:00
|
|
|
{ stdenv, cacert, git, cargo, cargo-vendor, python3 }:
|
2018-09-08 13:14:56 +01:00
|
|
|
let cargo-vendor-normalise = stdenv.mkDerivation {
|
|
|
|
name = "cargo-vendor-normalise";
|
|
|
|
src = ./cargo-vendor-normalise.py;
|
2018-09-17 19:21:21 +01:00
|
|
|
nativeBuildInputs = [ python3.pkgs.wrapPython ];
|
2019-06-19 16:45:34 +01:00
|
|
|
dontUnpack = true;
|
2018-09-08 13:14:56 +01:00
|
|
|
installPhase = "install -D $src $out/bin/cargo-vendor-normalise";
|
2018-09-17 19:21:21 +01:00
|
|
|
pythonPath = [ python3.pkgs.toml ];
|
|
|
|
postFixup = "wrapPythonPrograms";
|
2018-09-11 22:40:35 +01:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
# check that ./fetchcargo-default-config.toml is a fix point
|
|
|
|
reference=${./fetchcargo-default-config.toml}
|
|
|
|
< $reference $out/bin/cargo-vendor-normalise > test;
|
|
|
|
cmp test $reference
|
|
|
|
'';
|
2018-09-08 13:14:56 +01:00
|
|
|
preferLocalBuild = true;
|
|
|
|
};
|
|
|
|
in
|
2018-09-09 14:54:00 +01:00
|
|
|
{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "" }:
|
2014-10-10 15:59:37 +01:00
|
|
|
stdenv.mkDerivation {
|
2017-08-05 15:38:48 +01:00
|
|
|
name = "${name}-vendor";
|
2018-11-21 12:38:49 +00:00
|
|
|
nativeBuildInputs = [ cacert cargo-vendor git cargo-vendor-normalise cargo ];
|
2018-08-13 06:44:30 +01:00
|
|
|
inherit src srcs patches sourceRoot;
|
2015-05-29 18:35:31 +01:00
|
|
|
|
2018-08-13 06:44:30 +01:00
|
|
|
phases = "unpackPhase patchPhase installPhase";
|
2015-05-29 18:35:31 +01:00
|
|
|
|
|
|
|
installPhase = ''
|
2017-08-05 15:38:48 +01: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 11:05:14 +00:00
|
|
|
|
2017-08-05 15:38:48 +01:00
|
|
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
2018-11-25 14:20:24 +00:00
|
|
|
CARGO_CONFIG=$(mktemp cargo-config.XXXX)
|
2017-08-05 15:38:48 +01:00
|
|
|
|
2018-02-23 04:17:03 +00:00
|
|
|
${cargoUpdateHook}
|
|
|
|
|
2018-08-20 19:30:02 +01:00
|
|
|
mkdir -p $out
|
2018-11-25 14:20:24 +00:00
|
|
|
cargo vendor $out | cargo-vendor-normalise > $CARGO_CONFIG
|
2018-09-09 14:54:00 +01:00
|
|
|
# fetchcargo used to never keep the config output by cargo vendor
|
|
|
|
# and instead hardcode the config in ./fetchcargo-default-config.toml.
|
|
|
|
# This broke on packages needing git dependencies, so now we keep the config.
|
|
|
|
# But not to break old cargoSha256, if the previous behavior was enough,
|
|
|
|
# we don't store the config.
|
2018-11-25 14:20:24 +00:00
|
|
|
if ! cmp $CARGO_CONFIG ${./fetchcargo-default-config.toml} > /dev/null; then
|
2018-12-14 13:23:33 +00:00
|
|
|
install -D $CARGO_CONFIG $out/.cargo/config;
|
2018-09-09 14:54:00 +01:00
|
|
|
fi;
|
2015-05-29 18:35:31 +01:00
|
|
|
'';
|
2014-10-10 15:59:37 +01:00
|
|
|
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHash = sha256;
|
|
|
|
|
2016-09-17 20:50:01 +01:00
|
|
|
impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
|
2014-10-10 15:59:37 +01:00
|
|
|
preferLocalBuild = true;
|
|
|
|
}
|