2016-06-14 12:49:48 +02:00
|
|
|
{ stdenv, fetchurl, makeWrapper, cacert, zlib }:
|
2016-06-07 20:42:51 +02:00
|
|
|
|
|
|
|
let
|
2016-08-07 23:43:54 +02:00
|
|
|
inherit (stdenv.lib) optionalString;
|
|
|
|
|
2016-06-07 20:42:51 +02:00
|
|
|
platform =
|
|
|
|
if stdenv.system == "i686-linux"
|
|
|
|
then "i686-unknown-linux-gnu"
|
|
|
|
else if stdenv.system == "x86_64-linux"
|
|
|
|
then "x86_64-unknown-linux-gnu"
|
|
|
|
else if stdenv.system == "i686-darwin"
|
|
|
|
then "i686-apple-darwin"
|
|
|
|
else if stdenv.system == "x86_64-darwin"
|
|
|
|
then "x86_64-apple-darwin"
|
2017-03-09 02:37:14 +01:00
|
|
|
else throw "missing bootstrap url for platform ${stdenv.system}";
|
2016-06-07 20:42:51 +02:00
|
|
|
|
2017-02-03 14:53:09 +01:00
|
|
|
# fetch hashes by running `print-hashes.sh 1.14.0`
|
2016-06-07 20:42:51 +02:00
|
|
|
bootstrapHash =
|
|
|
|
if stdenv.system == "i686-linux"
|
2017-02-03 14:53:09 +01:00
|
|
|
then "8d5c75728b44468216f99651dfae9d60ae0696a77105dd2b02942d75f3256840"
|
2016-06-07 20:42:51 +02:00
|
|
|
else if stdenv.system == "x86_64-linux"
|
2017-02-03 14:53:09 +01:00
|
|
|
then "c71325cfea1b6f0bdc5189fa4c50ff96f828096ff3f7b5056367f9685d6a4d04"
|
2016-06-07 20:42:51 +02:00
|
|
|
else if stdenv.system == "i686-darwin"
|
2017-02-03 14:53:09 +01:00
|
|
|
then "fe1b3d67329a22d67e3b8db8858a43022e2e746dde60ef4a2db3f2cac16ea9bd"
|
2016-06-07 20:42:51 +02:00
|
|
|
else if stdenv.system == "x86_64-darwin"
|
2017-02-03 14:53:09 +01:00
|
|
|
then "3381341524b0184da5ed2cdcddc2a25e2e335e87f1cf676f64d98ee5e6479f20"
|
2017-03-09 02:37:14 +01:00
|
|
|
else throw "missing bootstrap hash for platform ${stdenv.system}";
|
2016-06-07 20:42:51 +02:00
|
|
|
|
2016-08-07 23:43:54 +02:00
|
|
|
needsPatchelf = stdenv.isLinux;
|
2016-07-29 12:14:51 +02:00
|
|
|
|
2016-06-07 20:42:51 +02:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://static.rust-lang.org/dist/rust-${version}-${platform}.tar.gz";
|
|
|
|
sha256 = bootstrapHash;
|
|
|
|
};
|
|
|
|
|
2017-02-03 14:53:09 +01:00
|
|
|
version = "1.14.0";
|
2016-06-14 12:49:48 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
rec {
|
|
|
|
rustc = stdenv.mkDerivation rec {
|
|
|
|
name = "rustc-bootstrap-${version}";
|
|
|
|
|
|
|
|
inherit version;
|
|
|
|
inherit src;
|
2016-06-07 20:42:51 +02:00
|
|
|
|
2016-06-14 12:49:48 +02:00
|
|
|
buildInputs = [ makeWrapper ];
|
|
|
|
phases = ["unpackPhase" "installPhase"];
|
2016-06-07 20:42:51 +02:00
|
|
|
|
2016-06-14 12:49:48 +02:00
|
|
|
installPhase = ''
|
|
|
|
./install.sh --prefix=$out \
|
|
|
|
--components=rustc,rust-std-${platform},rust-docs
|
2016-06-07 20:42:51 +02:00
|
|
|
|
2016-08-09 08:23:27 +02:00
|
|
|
${optionalString needsPatchelf ''
|
2016-07-29 12:14:51 +02:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
|
|
"$out/bin/rustc"
|
2016-08-09 08:23:27 +02:00
|
|
|
''}
|
2016-06-14 12:49:48 +02:00
|
|
|
|
2016-07-10 22:45:58 +02:00
|
|
|
# Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc
|
|
|
|
# (or similar) here. It causes strange effects where rustc loads
|
|
|
|
# the wrong libraries in a bootstrap-build causing failures that
|
|
|
|
# are very hard to track dow. For details, see
|
|
|
|
# https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943
|
2016-06-14 12:49:48 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
cargo = stdenv.mkDerivation rec {
|
|
|
|
name = "cargo-bootstrap-${version}";
|
|
|
|
|
|
|
|
inherit version;
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
buildInputs = [ makeWrapper zlib rustc ];
|
|
|
|
phases = ["unpackPhase" "installPhase"];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
./install.sh --prefix=$out \
|
|
|
|
--components=cargo
|
|
|
|
|
2016-08-09 08:23:27 +02:00
|
|
|
${optionalString needsPatchelf ''
|
2016-07-29 12:14:51 +02:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
|
|
"$out/bin/cargo"
|
2016-08-09 08:23:27 +02:00
|
|
|
''}
|
2016-06-14 12:49:48 +02:00
|
|
|
|
|
|
|
wrapProgram "$out/bin/cargo" \
|
|
|
|
--suffix PATH : "${rustc}/bin"
|
|
|
|
'';
|
|
|
|
};
|
2016-06-07 20:42:51 +02:00
|
|
|
}
|