at 23.11-beta 2.6 kB view raw
1{ lib, stdenv, makeWrapper, bash, curl, darwin, zlib 2, autoPatchelfHook, gcc 3, version 4, src 5, platform 6, versionType 7}: 8 9let 10 inherit (lib) optionalString; 11 inherit (darwin.apple_sdk.frameworks) Security; 12 13 bootstrapping = versionType == "bootstrap"; 14 15 installComponents 16 = "rustc,rust-std-${platform}" 17 + (optionalString bootstrapping ",cargo") 18 ; 19in 20 21rec { 22 rustc = stdenv.mkDerivation { 23 pname = "rustc-${versionType}"; 24 25 inherit version; 26 inherit src; 27 28 meta = with lib; { 29 homepage = "http://www.rust-lang.org/"; 30 description = "A safe, concurrent, practical language"; 31 maintainers = with maintainers; [ qknight ]; 32 license = [ licenses.mit licenses.asl20 ]; 33 }; 34 35 nativeBuildInputs = lib.optional (!stdenv.isDarwin) autoPatchelfHook; 36 buildInputs = [ bash ] 37 ++ lib.optionals (!stdenv.isDarwin) [ gcc.cc.lib zlib ] 38 ++ lib.optional stdenv.isDarwin Security; 39 40 postPatch = '' 41 patchShebangs . 42 ''; 43 44 installPhase = '' 45 ./install.sh --prefix=$out \ 46 --components=${installComponents} 47 48 # Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc 49 # (or similar) here. It causes strange effects where rustc loads 50 # the wrong libraries in a bootstrap-build causing failures that 51 # are very hard to track down. For details, see 52 # https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943 53 ''; 54 55 # The strip tool in cctools 973.0.1 and up appears to break rlibs in the 56 # binaries. The lib.rmeta object inside the ar archive should contain an 57 # .rmeta section, but it is removed. Luckily, this doesn't appear to be an 58 # issue for Rust builds produced by Nix. 59 dontStrip = true; 60 61 setupHooks = ./setup-hook.sh; 62 }; 63 64 cargo = stdenv.mkDerivation { 65 pname = "cargo-${versionType}"; 66 67 inherit version; 68 inherit src; 69 70 meta = with lib; { 71 homepage = "http://www.rust-lang.org/"; 72 description = "A safe, concurrent, practical language"; 73 maintainers = with maintainers; [ qknight ]; 74 license = [ licenses.mit licenses.asl20 ]; 75 }; 76 77 nativeBuildInputs = [ makeWrapper ] 78 ++ lib.optional (!stdenv.isDarwin) autoPatchelfHook; 79 buildInputs = [ bash ] 80 ++ lib.optional (!stdenv.isDarwin) gcc.cc.lib 81 ++ lib.optional stdenv.isDarwin Security; 82 83 postPatch = '' 84 patchShebangs . 85 ''; 86 87 installPhase = '' 88 patchShebangs ./install.sh 89 ./install.sh --prefix=$out \ 90 --components=cargo 91 92 wrapProgram "$out/bin/cargo" \ 93 --suffix PATH : "${rustc}/bin" 94 ''; 95 }; 96}