lol

Merge pull request #31125 from LnL7/darwin-rust-bootstrap

rust-bootstrap: cleanup darwin expression

authored by

Daiderd Jordan and committed by
GitHub
ccf7310e b7734b61

+38 -26
+35 -22
pkgs/development/compilers/rust/binaryBuild.nix
··· 1 - { stdenv, fetchurl, makeWrapper, cacert, zlib, buildRustPackage, curl 1 + { stdenv, fetchurl, makeWrapper, cacert, zlib, buildRustPackage, curl, darwin 2 2 , version 3 3 , src 4 4 , platform ··· 6 6 }: 7 7 8 8 let 9 - inherit (stdenv.lib) optionalString; 9 + inherit (stdenv.lib) getLib optionalString; 10 + inherit (darwin) libiconv; 11 + inherit (darwin.apple_sdk.frameworks) Security; 10 12 11 - needsPatchelf = stdenv.isLinux; 13 + bootstrapping = versionType == "bootstrap"; 12 14 13 - bootstrapping = versionType == "bootstrap"; 15 + patchBootstrapCargo = '' 16 + ${optionalString (stdenv.isLinux && bootstrapping) '' 17 + patchelf \ 18 + --set-rpath "${stdenv.lib.makeLibraryPath [ curl zlib ]}" \ 19 + --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 20 + "$out/bin/cargo" 21 + ''} 22 + ${optionalString (stdenv.isDarwin && bootstrapping) '' 23 + install_name_tool \ 24 + -change /usr/lib/libiconv.2.dylib '${getLib libiconv}/lib/libiconv.2.dylib' \ 25 + "$out/bin/cargo" 26 + install_name_tool \ 27 + -change /usr/lib/libcurl.4.dylib '${getLib curl}/lib/libcurl.4.dylib' \ 28 + "$out/bin/cargo" 29 + install_name_tool \ 30 + -change /usr/lib/libz.1.dylib '${getLib zlib}/lib/libz.1.dylib' \ 31 + "$out/bin/cargo" 32 + ''} 33 + ''; 14 34 15 35 installComponents 16 36 = "rustc,rust-std-${platform}" ··· 34 54 license = [ licenses.mit licenses.asl20 ]; 35 55 }; 36 56 37 - phases = ["unpackPhase" "installPhase"]; 57 + phases = ["unpackPhase" "installPhase" "fixupPhase"]; 58 + 59 + propagatedBuildInputs = stdenv.lib.optional stdenv.isDarwin Security; 38 60 39 61 installPhase = '' 40 62 ./install.sh --prefix=$out \ 41 63 --components=${installComponents} 42 64 43 - ${optionalString (needsPatchelf && bootstrapping) '' 65 + ${optionalString (stdenv.isLinux && bootstrapping) '' 44 66 patchelf \ 45 67 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 46 - "$out/bin/rustdoc" 68 + "$out/bin/rustc" 47 69 patchelf \ 48 - --set-rpath "${stdenv.lib.makeLibraryPath [ curl zlib ]}" \ 49 70 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 50 - "$out/bin/cargo" 71 + "$out/bin/rustdoc" 51 72 ''} 52 73 53 - ${optionalString needsPatchelf '' 54 - patchelf \ 55 - --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 56 - "$out/bin/rustc" 74 + ${patchBootstrapCargo} 57 75 58 76 # Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc 59 77 # (or similar) here. It causes strange effects where rustc loads 60 78 # the wrong libraries in a bootstrap-build causing failures that 61 79 # are very hard to track dow. For details, see 62 80 # https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943 63 - ''} 64 81 ''; 65 - 66 82 }; 67 83 68 84 cargo = stdenv.mkDerivation rec { ··· 78 94 license = [ licenses.mit licenses.asl20 ]; 79 95 }; 80 96 97 + phases = ["unpackPhase" "installPhase" "fixupPhase"]; 98 + 81 99 buildInputs = [ makeWrapper ]; 82 - phases = ["unpackPhase" "installPhase"]; 100 + propagatedBuildInputs = stdenv.lib.optional stdenv.isDarwin Security; 83 101 84 102 installPhase = '' 85 103 ./install.sh --prefix=$out \ 86 104 --components=cargo 87 105 88 - ${optionalString needsPatchelf '' 89 - patchelf \ 90 - --set-rpath "${stdenv.lib.makeLibraryPath [ curl zlib ]}" \ 91 - --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ 92 - "$out/bin/cargo" 93 - ''} 106 + ${patchBootstrapCargo} 94 107 95 108 wrapProgram "$out/bin/cargo" \ 96 109 --suffix PATH : "${rustc}/bin"
+3 -4
pkgs/development/compilers/rust/bootstrap.nix
··· 1 - { stdenv, fetchurl, makeWrapper, cacert, zlib, curl }: 1 + { stdenv, fetchurl, callPackage }: 2 2 3 3 let 4 4 # Note: the version MUST be one version prior to the version we're ··· 29 29 sha256 = hashes."${platform}"; 30 30 }; 31 31 32 - in import ./binaryBuild.nix 33 - { inherit stdenv fetchurl makeWrapper cacert zlib curl; 32 + in callPackage ./binaryBuild.nix 33 + { inherit version src platform; 34 34 buildRustPackage = null; 35 - inherit version src platform; 36 35 versionType = "bootstrap"; 37 36 }