mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 12:53:59 +03:00
rust: store the cargo-vendor config
cargo-vendor generates almost the right cargo config. Store it with the vendored files and patch it on use. This allows to re-use the generated config when using git dependencies.
This commit is contained in:
parent
c5456dbfec
commit
0af2c5891b
@ -2,11 +2,11 @@
|
||||
let
|
||||
inherit (stdenv) system;
|
||||
|
||||
version = "0.1.12";
|
||||
version = "0.1.13";
|
||||
|
||||
hashes = {
|
||||
x86_64-linux = "1hxlavcxy374yypfamlkygjg662lhll8j434qcvdawkvlidg5ii5";
|
||||
x86_64-darwin = "1jkvhh710gwjnnjx59kaplx2ncfvkx9agfa76rr94sbjqq4igddm";
|
||||
x86_64-linux = "1znv8hm4z4bfb6kncf95jv6h20qkmz3yhhr8f4vz2wamynklm9pr";
|
||||
x86_64-darwin = "0hcib4yli216qknjv7r2w8afakhl9yj19yyppp12c1p4pxhr1qr6";
|
||||
};
|
||||
hash = hashes. ${system} or badSystem;
|
||||
|
||||
|
@ -43,21 +43,15 @@ in stdenv.mkDerivation (args // {
|
||||
postUnpack = ''
|
||||
eval "$cargoDepsHook"
|
||||
|
||||
unpackFile "$cargoDeps"
|
||||
cargoDepsCopy=$(stripHash $(basename $cargoDeps))
|
||||
chmod -R +w "$cargoDepsCopy"
|
||||
if [[ ! -f $cargoDeps/.config ]]; then
|
||||
echo "ERROR: file not found: $cargoDeps/.config"
|
||||
echo "try updating the cargoSha256"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir .cargo
|
||||
cat >.cargo/config <<-EOF
|
||||
[source.crates-io]
|
||||
registry = 'https://github.com/rust-lang/crates.io-index'
|
||||
replace-with = 'vendored-sources'
|
||||
|
||||
[source.vendored-sources]
|
||||
directory = '$(pwd)/$cargoDepsCopy'
|
||||
EOF
|
||||
|
||||
unset cargoDepsCopy
|
||||
mkdir -p .cargo
|
||||
# inherit cargo config from the deps, rewrite the target directory
|
||||
cat $cargoDeps/.config | sed "s|REPLACEME|$cargoDeps|g" > .cargo/config
|
||||
|
||||
export RUST_LOG=${logLevel}
|
||||
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
|
||||
|
@ -22,9 +22,15 @@ stdenv.mkDerivation {
|
||||
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
|
||||
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
||||
|
||||
cargo vendor
|
||||
cargo vendor --locked | tee result.txt
|
||||
|
||||
cp -ar vendor $out
|
||||
mkdir $out
|
||||
|
||||
# keep the outputted cargo config but remove the target directory.
|
||||
# the target directory should be $out but that should change the sha256
|
||||
cat result.txt | sed "s|directory = \".*|directory = \"REPLACEME\"|" > $out/.config
|
||||
|
||||
cp -ar vendor/* $out/
|
||||
'';
|
||||
|
||||
outputHashAlgo = "sha256";
|
||||
|
@ -32,7 +32,7 @@ rec {
|
||||
cargo = callPackage ./cargo.nix rec {
|
||||
version = "0.23.0";
|
||||
srcSha = "14b2n1msxma19ydchj54hd7f2zdsr524fg133dkmdn7j65f1x6aj";
|
||||
cargoSha256 = "1sj59z0w172qvjwg1ma5fr5am9dgw27086xwdnrvlrk4hffcr7y7";
|
||||
cargoSha256 = "1mcqv45l0d1gw8v3v48gm1902xckj6r0s8l1z46nbmrsjs34rzhx";
|
||||
|
||||
inherit rustc; # the rustc that will be wrapped by cargo
|
||||
inherit rustPlatform; # used to build cargo
|
||||
|
Loading…
Reference in New Issue
Block a user