@@ -1,14 +1,11 @@
11{ stdenv, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps
2−, llvm, jemalloc, ncurses, darwin, binutils
2+, llvm, jemalloc, ncurses, darwin, binutils, rustc
33
4−, shortVersion, isRelease
4+, isRelease ? false
5+, shortVersion
56, forceBundledLLVM ? false
6−, srcSha, srcRev ? ""
7−, snapshotHashLinux686, snapshotHashLinux64
8−, snapshotHashDarwin686, snapshotHashDarwin64
9−, snapshotDate, snapshotRev
7+, srcSha, srcRev
108, configureFlags ? []
11−
129, patches
1310} @ args:
1411
@@ -26,9 +23,8 @@ sure those derivations still compile. (racer, for example).
2623
2724*/
2825
29−assert (if isRelease then srcRev == "" else srcRev != "");
30−
31−let version = if isRelease then
26+let
27+ version = if isRelease then
3228 "${shortVersion}"
3329 else
3430 "${shortVersion}-g${builtins.substring 0 7 srcRev}";
@@ -39,16 +35,6 @@ let version = if isRelease then
3935
4036 llvmShared = llvm.override { enableSharedLibraries = true; };
4137
42− platform = if stdenv.system == "i686-linux"
43− then "linux-i386"
44− else if stdenv.system == "x86_64-linux"
45− then "linux-x86_64"
46− else if stdenv.system == "i686-darwin"
47− then "macos-i386"
48− else if stdenv.system == "x86_64-darwin"
49− then "macos-x86_64"
50− else abort "no snapshot to bootstrap for this platform (missing platform url suffix)";
51−
5238 target = if stdenv.system == "i686-linux"
5339 then "i686-unknown-linux-gnu"
5440 else if stdenv.system == "x86_64-linux"
@@ -66,20 +52,9 @@ let version = if isRelease then
6652 license = [ licenses.mit licenses.asl20 ];
6753 platforms = platforms.linux ++ platforms.darwin;
6854 };
69−
70− snapshotHash = if stdenv.system == "i686-linux"
71− then snapshotHashLinux686
72− else if stdenv.system == "x86_64-linux"
73− then snapshotHashLinux64
74− else if stdenv.system == "i686-darwin"
75− then snapshotHashDarwin686
76− else if stdenv.system == "x86_64-darwin"
77− then snapshotHashDarwin64
78− else abort "no snapshot for platform ${stdenv.system}";
79− snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshotHash}.tar.bz2";
8055in
8156
82−with stdenv.lib; stdenv.mkDerivation {
57+stdenv.mkDerivation {
8358 inherit name;
8459 inherit version;
8560 inherit meta;
@@ -88,42 +63,19 @@ with stdenv.lib; stdenv.mkDerivation {
8863
8964 NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-rpath ${llvmShared}/lib";
9065
91− src = if isRelease then
92− fetchzip {
93− url = "http://static.rust-lang.org/dist/rustc-${version}-src.tar.gz";
94− sha256 = srcSha;
95− }
96− else
97− fetchgit {
98− url = https://github.com/rust-lang/rust;
99− rev = srcRev;
100− sha256 = srcSha;
101− };
102−
103− # We need rust to build rust. If we don't provide it, configure will try to download it.
104− snapshot = stdenv.mkDerivation {
105− name = "rust-stage0";
106− src = fetchurl {
107− url = "http://static.rust-lang.org/stage0-snapshots/${snapshotName}";
108− sha1 = snapshotHash;
109− };
110− dontStrip = true;
111− installPhase = ''
112− mkdir -p "$out"
113− cp -r bin "$out/bin"
114− '' + optionalString stdenv.isLinux ''
115− patchelf --interpreter "${stdenv.glibc.out}/lib/${stdenv.cc.dynamicLinker}" \
116− --set-rpath "${stdenv.cc.cc.lib}/lib/:${stdenv.cc.cc.lib}/lib64/" \
117− "$out/bin/rustc"
118− '';
66+ src = fetchgit {
67+ url = https://github.com/rust-lang/rust;
68+ rev = srcRev;
69+ sha256 = srcSha;
11970 };
12071
72+ # We need rust to build rust. If we don't provide it, configure will try to download it.
12173 configureFlags = configureFlags
122− ++ [ "--enable-local-rust" "--local-rust-root=$snapshot" "--enable-rpath" ]
74+ ++ [ "--enable-local-rust" "--local-rust-root=${rustc}" "--enable-rpath" ]
12375 # ++ [ "--jemalloc-root=${jemalloc}/lib"
12476 ++ [ "--default-linker=${stdenv.cc}/bin/cc" "--default-ar=${binutils.out}/bin/ar" ]
125− ++ optional (stdenv.cc.cc ? isClang) "--enable-clang"
126− ++ optional (!forceBundledLLVM) "--llvm-root=${llvmShared}";
77+ ++ stdenv.lib.optional (stdenv.cc.cc ? isClang) "--enable-clang"
78+ ++ stdenv.lib.optional (!forceBundledLLVM) "--llvm-root=${llvmShared}";
12779
12880 inherit patches;
12981
@@ -138,7 +90,7 @@ with stdenv.lib; stdenv.mkDerivation {
13890 --replace "\$\$(subst /,//," "\$\$(subst /,/,"
13991
14092 # Fix dynamic linking against llvm
141− ${optionalString (!forceBundledLLVM) ''sed -i 's/, kind = \\"static\\"//g' src/etc/mklldeps.py''}
93+ ${stdenv.lib.optionalString (!forceBundledLLVM) ''sed -i 's/, kind = \\"static\\"//g' src/etc/mklldeps.py''}
14294
14395 # Fix the configure script to not require curl as we won't use it
14496 sed -i configure \
@@ -160,9 +112,9 @@ with stdenv.lib; stdenv.mkDerivation {
160112 '';
161113
162114 # ps is needed for one of the test cases
163− nativeBuildInputs = [ file python2 procps ];
115+ nativeBuildInputs = [ file python2 procps rustc ];
164116 buildInputs = [ ncurses ]
165− ++ optional (!forceBundledLLVM) llvmShared;
117+ ++ stdenv.lib.optional (!forceBundledLLVM) llvmShared;
166118
167119 # https://github.com/rust-lang/rust/issues/30181
168120 # enableParallelBuilding = false; # missing files during linking, occasionally