about summary refs log tree commit diff
path: root/pkgs/build-support/rust
diff options
context:
space:
mode:
authorRicardo M. Correia <rcorreia@wizy.org>2015-11-17 19:32:03 +0100
committerRicardo M. Correia <rcorreia@wizy.org>2015-11-18 02:41:45 +0100
commit2b694c237b5a19594774420a6929a9470ad81a28 (patch)
tree2f34430633926a3adc66cc33134f1a76af4f9856 /pkgs/build-support/rust
parent893179e9c1fa53e42043e9dc09e11c75d87ac00e (diff)
downloadnixlib-2b694c237b5a19594774420a6929a9470ad81a28.tar
nixlib-2b694c237b5a19594774420a6929a9470ad81a28.tar.gz
nixlib-2b694c237b5a19594774420a6929a9470ad81a28.tar.bz2
nixlib-2b694c237b5a19594774420a6929a9470ad81a28.tar.lz
nixlib-2b694c237b5a19594774420a6929a9470ad81a28.tar.xz
nixlib-2b694c237b5a19594774420a6929a9470ad81a28.tar.zst
nixlib-2b694c237b5a19594774420a6929a9470ad81a28.zip
cargo, cargoSnapshot: add rustc runtime dependency
It turns out that cargo implicitly depends on rustc at runtime: even
`cargo help` will fail if rustc is not in the PATH.

This means that we need to wrap the cargo binary to add rustc to PATH.
However, I have opted into doing something slightly unusual: instead of
tying down a specific cargo to use a specific rustc (i.e., wrap cargo so
that "${rustc}/bin" is prefixed into PATH), instead I'm adding the rustc
used to build cargo as a fallback rust compiler (i.e., wrap cargo so
that "${rustc}/bin" is suffixed into PATH). This means that cargo will
prefer to use a rust compiler that is in the default path, but fallback
into the one used to build cargo only if there wasn't any rust compiler
in the default path.

The reason I'm doing this is that otherwise it could cause unexpected
effects. For example, if you had a build environment with the
rustcMaster and cargo derivations, you would expect cargo to use
rustcMaster to compile your project (since rustcMaster would be the only
compiler available in $PATH), but this wouldn't happen if we tied down
cargo to use the rustc that was used to compile it (because the default
cargo derivation gets compiled with the stable rust compiler).

That said, I have slightly modified makeRustPlatform so that a rust
platform will always use the rust compiler that was used to build cargo,
because this prevents mistakenly depending on two different versions of
the rust compiler (stable and unstable) in the same rust platform,
something which is usually undesirable.

Fixes #11053
Diffstat (limited to 'pkgs/build-support/rust')
-rw-r--r--pkgs/build-support/rust/default.nix6
-rw-r--r--pkgs/build-support/rust/fetchcargo.nix4
2 files changed, 5 insertions, 5 deletions
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix
index c23581d96019..e0d451417780 100644
--- a/pkgs/build-support/rust/default.nix
+++ b/pkgs/build-support/rust/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, cacert, git, rustc, cargo, rustRegistry }:
+{ stdenv, cacert, git, cargo, rustRegistry }:
 { name, depsSha256
 , src ? null
 , srcs ? null
@@ -9,7 +9,7 @@
 
 let
   fetchDeps = import ./fetchcargo.nix {
-    inherit stdenv cacert git rustc cargo rustRegistry;
+    inherit stdenv cacert git cargo rustRegistry;
   };
 
   cargoDeps = fetchDeps {
@@ -22,7 +22,7 @@ in stdenv.mkDerivation (args // {
 
   patchRegistryDeps = ./patch-registry-deps;
 
-  buildInputs = [ git cargo rustc ] ++ buildInputs;
+  buildInputs = [ git cargo cargo.rustc ] ++ buildInputs;
 
   configurePhase = args.configurePhase or "true";
 
diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix
index 0ce1d0a11d32..95eefbedc327 100644
--- a/pkgs/build-support/rust/fetchcargo.nix
+++ b/pkgs/build-support/rust/fetchcargo.nix
@@ -1,9 +1,9 @@
-{ stdenv, cacert, git, rustc, cargo, rustRegistry }:
+{ stdenv, cacert, git, cargo, rustRegistry }:
 { name ? "cargo-deps", src, srcs, sourceRoot, sha256, cargoUpdateHook ? "" }:
 
 stdenv.mkDerivation {
   name = "${name}-fetch";
-  buildInputs = [ rustc cargo git ];
+  buildInputs = [ cargo git ];
   inherit src srcs sourceRoot rustRegistry cargoUpdateHook;
 
   phases = "unpackPhase installPhase";