at 22.05-pre 2.9 kB view raw
1{ lib, stdenv, makeWrapper, bash, curl, darwin, zlib 2, version 3, src 4, platform 5, versionType 6}: 7 8let 9 inherit (lib) optionalString; 10 inherit (darwin.apple_sdk.frameworks) Security; 11 12 bootstrapping = versionType == "bootstrap"; 13 14 installComponents 15 = "rustc,rust-std-${platform}" 16 + (optionalString bootstrapping ",cargo") 17 ; 18in 19 20rec { 21 rustc = stdenv.mkDerivation { 22 name = "rustc-${versionType}-${version}"; 23 24 inherit version; 25 inherit src; 26 27 meta = with lib; { 28 homepage = "http://www.rust-lang.org/"; 29 description = "A safe, concurrent, practical language"; 30 maintainers = with maintainers; [ qknight ]; 31 license = [ licenses.mit licenses.asl20 ]; 32 }; 33 34 buildInputs = [ bash ] 35 ++ lib.optional stdenv.isDarwin Security; 36 37 postPatch = '' 38 patchShebangs . 39 ''; 40 41 installPhase = '' 42 ./install.sh --prefix=$out \ 43 --components=${installComponents} 44 45 ${optionalString (stdenv.isLinux && bootstrapping) ('' 46 patchelf \ 47 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 48 "$out/bin/rustc" 49 '' + optionalString (lib.versionAtLeast version "1.46") 50 # rustc bootstrap needs libz starting from 1.46 51 '' 52 ln -s ${zlib}/lib/libz.so.1 $out/lib/libz.so.1 53 ln -s ${zlib}/lib/libz.so $out/lib/libz.so 54 '' + '' 55 patchelf \ 56 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 57 "$out/bin/rustdoc" 58 patchelf \ 59 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 60 "$out/bin/cargo" 61 '')} 62 63 # Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc 64 # (or similar) here. It causes strange effects where rustc loads 65 # the wrong libraries in a bootstrap-build causing failures that 66 # are very hard to track down. For details, see 67 # https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943 68 ''; 69 70 setupHooks = ./setup-hook.sh; 71 }; 72 73 cargo = stdenv.mkDerivation { 74 name = "cargo-${versionType}-${version}"; 75 76 inherit version; 77 inherit src; 78 79 meta = with lib; { 80 homepage = "http://www.rust-lang.org/"; 81 description = "A safe, concurrent, practical language"; 82 maintainers = with maintainers; [ qknight ]; 83 license = [ licenses.mit licenses.asl20 ]; 84 }; 85 86 nativeBuildInputs = [ makeWrapper ]; 87 buildInputs = [ bash ] ++ lib.optional stdenv.isDarwin Security; 88 89 postPatch = '' 90 patchShebangs . 91 ''; 92 93 installPhase = '' 94 patchShebangs ./install.sh 95 ./install.sh --prefix=$out \ 96 --components=cargo 97 98 ${optionalString (stdenv.isLinux && bootstrapping) '' 99 patchelf \ 100 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 101 "$out/bin/cargo" 102 ''} 103 104 wrapProgram "$out/bin/cargo" \ 105 --suffix PATH : "${rustc}/bin" 106 ''; 107 }; 108}