2014-01-15 14:25:23 +00:00
|
|
|
{stdenv, fetchurl, which, file, perl, curl, python27, makeWrapper}:
|
|
|
|
|
2014-01-20 16:05:29 +00:00
|
|
|
/* Rust's build process has a few quirks :
|
|
|
|
|
|
|
|
- It requires some patched in llvm that haven't landed upstream, so it
|
|
|
|
compiles its own llvm. This might change in the future, so at some
|
|
|
|
point we may be able to switch to nix's llvm.
|
|
|
|
|
|
|
|
- The Rust compiler is written is Rust, so it requires a bootstrap
|
|
|
|
compiler, which is downloaded during the build. To make the build
|
|
|
|
pure, we download it ourself before and put it where it is
|
|
|
|
expected. Once the language is stable (1.0) , we might want to
|
|
|
|
switch it to use nix's packaged rust compiler.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2014-01-19 19:42:38 +00:00
|
|
|
with if stdenv.system == "i686-linux" then {
|
|
|
|
platform = "linux-i386";
|
2014-07-02 20:43:34 +01:00
|
|
|
snapshot = "84339ea0f796ae468ef86797ef4587274bec19ea";
|
2014-01-22 18:20:52 +00:00
|
|
|
target = "i686-unknown-linux-gnu";
|
2014-01-19 19:42:38 +00:00
|
|
|
} else if stdenv.system == "x86_64-linux" then {
|
|
|
|
platform = "linux-x86_64";
|
2014-07-02 20:43:34 +01:00
|
|
|
snapshot = "bd8a6bc1f28845b7f4b768f6bfa06e7fbdcfcaae";
|
2014-01-19 19:42:38 +00:00
|
|
|
target = "x86_64-unknown-linux-gnu";
|
|
|
|
} else if stdenv.system == "x86_64-darwin" then {
|
|
|
|
platform = "macos-x86_64";
|
2014-07-02 20:43:34 +01:00
|
|
|
snapshot = "4a8c2e1b7634d73406bac32a1a97893ec3ed818d";
|
2014-01-19 19:42:38 +00:00
|
|
|
} else {};
|
2014-07-02 20:43:34 +01:00
|
|
|
let snapshotDate = "2014-06-21";
|
|
|
|
snapshotRev = "db9af1d";
|
2014-01-19 19:42:38 +00:00
|
|
|
snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshot}.tar.bz2"; in
|
2014-01-15 14:25:23 +00:00
|
|
|
stdenv.mkDerivation {
|
2014-07-02 20:43:34 +01:00
|
|
|
name = "rust-0.11.0";
|
2014-01-19 17:40:31 +00:00
|
|
|
|
2014-01-15 14:25:23 +00:00
|
|
|
src = fetchurl {
|
2014-07-02 20:43:34 +01:00
|
|
|
url = http://static.rust-lang.org/dist/rust-0.11.0.tar.gz;
|
|
|
|
sha256 = "1fhi8iiyyj5j48fpnp93sfv781z1dm0xy94h534vh4mz91jf7cyi";
|
2014-01-15 14:25:23 +00:00
|
|
|
};
|
|
|
|
|
2014-04-25 21:40:51 +01:00
|
|
|
# We need rust to build rust. If we don't provide it, configure will try to download it.
|
|
|
|
snapshot = stdenv.mkDerivation {
|
|
|
|
name = "rust-stage0";
|
|
|
|
src = fetchurl {
|
|
|
|
url = "http://static.rust-lang.org/stage0-snapshots/${snapshotName}";
|
2014-07-02 20:43:34 +01:00
|
|
|
sha1 = snapshot;
|
2014-04-25 21:40:51 +01:00
|
|
|
};
|
2014-07-02 20:43:34 +01:00
|
|
|
dontStrip = true;
|
2014-04-25 21:40:51 +01:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out"
|
|
|
|
cp -r bin "$out/bin"
|
|
|
|
'' + (if stdenv.isLinux then ''
|
2014-07-02 20:43:34 +01:00
|
|
|
patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.gcc.dynamicLinker}" \
|
|
|
|
--set-rpath "${stdenv.gcc.gcc}/lib/:${stdenv.gcc.gcc}/lib64/" \
|
|
|
|
"$out/bin/rustc"
|
2014-04-25 21:40:51 +01:00
|
|
|
'' else "");
|
2014-01-15 14:25:23 +00:00
|
|
|
};
|
|
|
|
|
2014-04-25 21:40:51 +01:00
|
|
|
configureFlags = [ "--enable-local-rust" "--local-rust-root=$snapshot" ];
|
2014-01-15 14:25:23 +00:00
|
|
|
|
2014-01-20 16:05:29 +00:00
|
|
|
# The compiler requires cc, so we patch the source to tell it where to find it
|
2014-04-25 21:40:51 +01:00
|
|
|
patches = [ ./hardcode_paths.patch ./local_stage0.patch ];
|
2014-01-20 16:05:29 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src/librustc/back/link.rs \
|
2014-07-02 20:43:34 +01:00
|
|
|
--subst-var-by "ccPath" "${stdenv.gcc}/bin/cc" \
|
|
|
|
--subst-var-by "arPath" "${stdenv.gcc.binutils}/bin/ar"
|
2014-01-20 16:05:29 +00:00
|
|
|
'';
|
|
|
|
|
2014-01-19 17:40:31 +00:00
|
|
|
buildInputs = [ which file perl curl python27 makeWrapper ];
|
2014-01-15 14:25:23 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2014-04-25 21:40:51 +01:00
|
|
|
meta = with stdenv.lib; {
|
2014-01-15 14:25:23 +00:00
|
|
|
homepage = http://www.rust-lang.org/;
|
|
|
|
description = "A safe, concurrent, practical language";
|
2014-04-25 21:40:51 +01:00
|
|
|
maintainers = with maintainers; [ madjar cstrahan ];
|
|
|
|
license = map (builtins.getAttr "shortName") [ licenses.mit licenses.asl20 ];
|
2014-01-15 14:25:23 +00:00
|
|
|
# platforms as per http://static.rust-lang.org/doc/master/tutorial.html#getting-started
|
2014-01-19 17:40:31 +00:00
|
|
|
platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
|
2014-01-15 14:25:23 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|