2016-06-14 10:49:48 +00:00
|
|
|
{ stdenv, fetchurl, makeWrapper, cacert, zlib }:
|
2016-06-07 18:42:51 +00:00
|
|
|
|
|
|
|
let
|
2016-08-07 21:43:54 +00:00
|
|
|
inherit (stdenv.lib) optionalString;
|
|
|
|
|
2016-06-07 18:42:51 +00: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"
|
|
|
|
else abort "missing boostrap url for platform ${stdenv.system}";
|
|
|
|
|
|
|
|
# fetch hashes by running `print-hashes.sh 1.9.0`
|
|
|
|
bootstrapHash =
|
|
|
|
if stdenv.system == "i686-linux"
|
2016-10-11 01:59:26 +00:00
|
|
|
then "f5a3f5d53defe827a71447b1a0e7a656394b87ee23e009d7bf73a0277c1b5ac2"
|
2016-06-07 18:42:51 +00:00
|
|
|
else if stdenv.system == "x86_64-linux"
|
2016-10-11 01:59:26 +00:00
|
|
|
then "f4ebbd6d9494cb8fa6c410cb58954e1913546c2bca8963faebc424591547d83f"
|
2016-06-07 18:42:51 +00:00
|
|
|
else if stdenv.system == "i686-darwin"
|
2016-10-11 01:59:26 +00:00
|
|
|
then "bf07182bc362985fcdd48af905cdb559e20c68518cd71dabec3c30b78ca8a94a"
|
2016-06-07 18:42:51 +00:00
|
|
|
else if stdenv.system == "x86_64-darwin"
|
2016-10-11 01:59:26 +00:00
|
|
|
then "2cdbc47438dc86ecaf35298317b77d735956eb160862e3f6d0fda0da656ecc35"
|
2016-06-07 18:42:51 +00:00
|
|
|
else throw "missing boostrap hash for platform ${stdenv.system}";
|
|
|
|
|
2016-08-07 21:43:54 +00:00
|
|
|
needsPatchelf = stdenv.isLinux;
|
2016-07-29 10:14:51 +00:00
|
|
|
|
2016-06-07 18:42:51 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://static.rust-lang.org/dist/rust-${version}-${platform}.tar.gz";
|
|
|
|
sha256 = bootstrapHash;
|
|
|
|
};
|
|
|
|
|
2016-10-11 01:59:26 +00:00
|
|
|
version = "1.11.0";
|
2016-06-14 10:49:48 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
rec {
|
|
|
|
rustc = stdenv.mkDerivation rec {
|
|
|
|
name = "rustc-bootstrap-${version}";
|
|
|
|
|
|
|
|
inherit version;
|
|
|
|
inherit src;
|
2016-06-07 18:42:51 +00:00
|
|
|
|
2016-06-14 10:49:48 +00:00
|
|
|
buildInputs = [ makeWrapper ];
|
|
|
|
phases = ["unpackPhase" "installPhase"];
|
2016-06-07 18:42:51 +00:00
|
|
|
|
2016-06-14 10:49:48 +00:00
|
|
|
installPhase = ''
|
|
|
|
./install.sh --prefix=$out \
|
|
|
|
--components=rustc,rust-std-${platform},rust-docs
|
2016-06-07 18:42:51 +00:00
|
|
|
|
2016-08-09 06:23:27 +00:00
|
|
|
${optionalString needsPatchelf ''
|
2016-07-29 10:14:51 +00:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
|
|
"$out/bin/rustc"
|
2016-08-09 06:23:27 +00:00
|
|
|
''}
|
2016-06-14 10:49:48 +00:00
|
|
|
|
2016-07-10 20:45:58 +00: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 10:49:48 +00: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 06:23:27 +00:00
|
|
|
${optionalString needsPatchelf ''
|
2016-07-29 10:14:51 +00:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
|
|
"$out/bin/cargo"
|
2016-08-09 06:23:27 +00:00
|
|
|
''}
|
2016-06-14 10:49:48 +00:00
|
|
|
|
|
|
|
wrapProgram "$out/bin/cargo" \
|
|
|
|
--suffix PATH : "${rustc}/bin"
|
|
|
|
'';
|
|
|
|
};
|
2016-06-07 18:42:51 +00:00
|
|
|
}
|