about summary refs log tree commit diff
diff options
context:
space:
mode:
authorzimbatm <zimbatm@zimbatm.com>2017-10-23 16:13:08 +0000
committerRobin Gloster <mail@glob.in>2018-01-09 03:37:53 +0100
commit0af2c5891bfccfe5a6e8ba67e95c5852c45529d2 (patch)
tree50d0faf1dd578ea311ec4d316a5e0060e8ce16f8
parentc5456dbfec07f371d9afec008b443dc5bf9a305d (diff)
downloadnixlib-0af2c5891bfccfe5a6e8ba67e95c5852c45529d2.tar
nixlib-0af2c5891bfccfe5a6e8ba67e95c5852c45529d2.tar.gz
nixlib-0af2c5891bfccfe5a6e8ba67e95c5852c45529d2.tar.bz2
nixlib-0af2c5891bfccfe5a6e8ba67e95c5852c45529d2.tar.lz
nixlib-0af2c5891bfccfe5a6e8ba67e95c5852c45529d2.tar.xz
nixlib-0af2c5891bfccfe5a6e8ba67e95c5852c45529d2.tar.zst
nixlib-0af2c5891bfccfe5a6e8ba67e95c5852c45529d2.zip
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.
-rw-r--r--pkgs/build-support/rust/cargo-vendor.nix6
-rw-r--r--pkgs/build-support/rust/default.nix24
-rw-r--r--pkgs/build-support/rust/fetchcargo.nix10
-rw-r--r--pkgs/development/compilers/rust/default.nix2
4 files changed, 21 insertions, 21 deletions
diff --git a/pkgs/build-support/rust/cargo-vendor.nix b/pkgs/build-support/rust/cargo-vendor.nix
index 9c379eaa3337..95ee7d2b989d 100644
--- a/pkgs/build-support/rust/cargo-vendor.nix
+++ b/pkgs/build-support/rust/cargo-vendor.nix
@@ -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;
 
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix
index 57948c33bbc3..e3ede9372dfc 100644
--- a/pkgs/build-support/rust/default.nix
+++ b/pkgs/build-support/rust/default.nix
@@ -43,21 +43,15 @@ in stdenv.mkDerivation (args // {
   postUnpack = ''
     eval "$cargoDepsHook"
 
-    unpackFile "$cargoDeps"
-    cargoDepsCopy=$(stripHash $(basename $cargoDeps))
-    chmod -R +w "$cargoDepsCopy"
-
-    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
+    if [[ ! -f $cargoDeps/.config ]]; then
+      echo "ERROR: file not found: $cargoDeps/.config"
+      echo "try updating the cargoSha256"
+      exit 1
+    fi
+
+    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
diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix
index 9b3ba5303398..b8e55606473d 100644
--- a/pkgs/build-support/rust/fetchcargo.nix
+++ b/pkgs/build-support/rust/fetchcargo.nix
@@ -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";
diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix
index b5550a96a835..6ab0ecaf1553 100644
--- a/pkgs/development/compilers/rust/default.nix
+++ b/pkgs/development/compilers/rust/default.nix
@@ -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