Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.03 2.7 kB view raw
1{ stdenv, makeWrapper, bash, curl, darwin 2, version 3, src 4, platform 5, versionType 6}: 7 8let 9 inherit (stdenv.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 stdenv.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 ++ stdenv.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 patchelf \ 50 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 51 "$out/bin/rustdoc" 52 patchelf \ 53 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 54 "$out/bin/cargo" 55 ''} 56 57 # Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc 58 # (or similar) here. It causes strange effects where rustc loads 59 # the wrong libraries in a bootstrap-build causing failures that 60 # are very hard to track down. For details, see 61 # https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943 62 ''; 63 64 setupHooks = ./setup-hook.sh; 65 }; 66 67 cargo = stdenv.mkDerivation { 68 name = "cargo-${versionType}-${version}"; 69 70 inherit version; 71 inherit src; 72 73 meta = with stdenv.lib; { 74 homepage = http://www.rust-lang.org/; 75 description = "A safe, concurrent, practical language"; 76 maintainers = with maintainers; [ qknight ]; 77 license = [ licenses.mit licenses.asl20 ]; 78 }; 79 80 buildInputs = [ makeWrapper bash ] 81 ++ stdenv.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 ${optionalString (stdenv.isLinux && bootstrapping) '' 93 patchelf \ 94 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 95 "$out/bin/cargo" 96 ''} 97 98 wrapProgram "$out/bin/cargo" \ 99 --suffix PATH : "${rustc}/bin" 100 ''; 101 }; 102}