diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index c23581d9601..e0d45141778 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 0ce1d0a11d3..95eefbedc32 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"; diff --git a/pkgs/development/tools/build-managers/cargo/common.nix b/pkgs/development/tools/build-managers/cargo/common.nix index 94b9ca1f665..941fe807307 100644 --- a/pkgs/development/tools/build-managers/cargo/common.nix +++ b/pkgs/development/tools/build-managers/cargo/common.nix @@ -1,4 +1,4 @@ -{stdenv, version}: +{stdenv, version, rustc}: { inherit version; @@ -11,6 +11,8 @@ "$out/lib/rustlib/rust-installer-version" \ "$out/lib/rustlib/uninstall.sh" \ "$out/lib/rustlib/manifest-cargo" + + wrapProgram "$out/bin/cargo" --suffix PATH : "${rustc}/bin" ''; platform = if stdenv.system == "i686-linux" @@ -23,6 +25,8 @@ then "x86_64-apple-darwin" else throw "no snapshot to bootstrap for this platform (missing platform url suffix)"; + passthru.rustc = rustc; + meta = with stdenv.lib; { homepage = http://crates.io; description = "Downloads your Rust project's dependencies and builds your project"; diff --git a/pkgs/development/tools/build-managers/cargo/default.nix b/pkgs/development/tools/build-managers/cargo/default.nix index c614e8c2386..bdd6c18e92c 100644 --- a/pkgs/development/tools/build-managers/cargo/default.nix +++ b/pkgs/development/tools/build-managers/cargo/default.nix @@ -1,12 +1,15 @@ { stdenv, fetchgit, rustPlatform, file, curl, python, pkgconfig, openssl -, cmake, zlib }: - -with ((import ./common.nix) { inherit stdenv; version = "0.6.0"; }); +, cmake, zlib, makeWrapper }: with rustPlatform; +with ((import ./common.nix) { + inherit stdenv rustc; + version = "0.6.0"; +}); + buildRustPackage rec { - inherit name version meta; + inherit name version meta passthru; # Needs to use fetchgit instead of fetchFromGitHub to fetch submodules src = fetchgit { @@ -17,7 +20,7 @@ buildRustPackage rec { depsSha256 = "1m045yywv67sx75idbsny59d3dzbqnhr07k41jial5n5zwp87mb9"; - buildInputs = [ file curl pkgconfig python openssl cmake zlib ]; + buildInputs = [ file curl pkgconfig python openssl cmake zlib makeWrapper ]; configurePhase = '' ./configure --enable-optimize --prefix=$out --local-cargo=${cargo}/bin/cargo diff --git a/pkgs/development/tools/build-managers/cargo/snapshot.nix b/pkgs/development/tools/build-managers/cargo/snapshot.nix index f24bcc2d9ab..ad07148815b 100644 --- a/pkgs/development/tools/build-managers/cargo/snapshot.nix +++ b/pkgs/development/tools/build-managers/cargo/snapshot.nix @@ -1,11 +1,14 @@ -{ stdenv, fetchurl, zlib }: +{ stdenv, fetchurl, zlib, makeWrapper, rustc }: /* Cargo binary snapshot */ let snapshotDate = "2015-06-17"; in -with ((import ./common.nix) { inherit stdenv; version = "snapshot-${snapshotDate}"; }); +with ((import ./common.nix) { + inherit stdenv rustc; + version = "snapshot-${snapshotDate}"; +}); let snapshotHash = if stdenv.system == "i686-linux" then "g2h9l35123r72hqdwayd9h79kspfb4y9" @@ -20,23 +23,23 @@ let snapshotHash = if stdenv.system == "i686-linux" in stdenv.mkDerivation { - inherit name version meta; + inherit name version meta passthru; src = fetchurl { url = "https://static-rust-lang-org.s3.amazonaws.com/cargo-dist/${snapshotDate}/${snapshotName}"; sha1 = snapshotHash; }; + buildInputs = [ makeWrapper ]; + dontStrip = true; installPhase = '' mkdir -p "$out" ./install.sh "--prefix=$out" - - ${postInstall} '' + (if stdenv.isLinux then '' patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.cc.dynamicLinker}" \ --set-rpath "${stdenv.cc.cc}/lib/:${stdenv.cc.cc}/lib64/:${zlib}/lib" \ "$out/bin/cargo" - '' else ""); + '' else "") + postInstall; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 744ad14e4c9..8fcc8a6b419 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4773,23 +4773,27 @@ let rustPlatform = rustStable; - rustStable = recurseIntoAttrs (makeRustPlatform rustc cargo rustStable); - rustUnstable = recurseIntoAttrs (makeRustPlatform rustcMaster - (cargo.override { rustPlatform = rustUnstableCargoPlatform; }) rustUnstable); + rustStable = recurseIntoAttrs (makeRustPlatform cargo rustStable); + rustUnstable = recurseIntoAttrs (makeRustPlatform + (cargo.override { rustPlatform = rustUnstableCargoPlatform; }) rustUnstable); # rust platform to build cargo itself (with cargoSnapshot) - rustCargoPlatform = makeRustPlatform rustc cargoSnapshot.cargo rustCargoPlatform; - rustUnstableCargoPlatform = makeRustPlatform rustcMaster cargoSnapshot.cargo rustUnstableCargoPlatform; + rustCargoPlatform = makeRustPlatform (cargoSnapshot rustc) rustCargoPlatform; + rustUnstableCargoPlatform = makeRustPlatform (cargoSnapshot rustcMaster) rustUnstableCargoPlatform; - makeRustPlatform = rustc: cargo: self: + makeRustPlatform = cargo: self: let callPackage = newScope self; in { - inherit rustc cargo; + inherit cargo; + + rustc = cargo.rustc; rustRegistry = callPackage ./rust-packages.nix { }; - buildRustPackage = callPackage ../build-support/rust { }; + buildRustPackage = callPackage ../build-support/rust { + inherit cargo; + }; }; rustfmt = callPackage ../development/tools/rust/rustfmt { }; @@ -5422,9 +5426,10 @@ let rustPlatform = rustCargoPlatform; }; - cargoSnapshot = { - cargo = callPackage ../development/tools/build-managers/cargo/snapshot.nix { }; - }; + cargoSnapshot = rustc: + callPackage ../development/tools/build-managers/cargo/snapshot.nix { + inherit rustc; + }; casperjs = callPackage ../development/tools/casperjs { };