rust-bootstrap: cleanup darwin expressions
This commit is contained in:
parent
c8dd4e7626
commit
c72b22c420
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, fetchurl, makeWrapper, cacert, zlib, buildRustPackage, curl
|
{ stdenv, fetchurl, makeWrapper, cacert, zlib, buildRustPackage, curl, darwin
|
||||||
, version
|
, version
|
||||||
, src
|
, src
|
||||||
, platform
|
, platform
|
||||||
@ -6,12 +6,32 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (stdenv.lib) optionalString;
|
inherit (stdenv.lib) getLib optionalString;
|
||||||
|
inherit (darwin) libiconv;
|
||||||
needsPatchelf = stdenv.isLinux;
|
inherit (darwin.apple_sdk.frameworks) Security;
|
||||||
|
|
||||||
bootstrapping = versionType == "bootstrap";
|
bootstrapping = versionType == "bootstrap";
|
||||||
|
|
||||||
|
patchBootstrapCargo = ''
|
||||||
|
${optionalString (stdenv.isLinux && bootstrapping) ''
|
||||||
|
patchelf \
|
||||||
|
--set-rpath "${stdenv.lib.makeLibraryPath [ curl zlib ]}" \
|
||||||
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||||
|
"$out/bin/cargo"
|
||||||
|
''}
|
||||||
|
${optionalString (stdenv.isDarwin && bootstrapping) ''
|
||||||
|
install_name_tool \
|
||||||
|
-change /usr/lib/libiconv.2.dylib '${getLib libiconv}/lib/libiconv.2.dylib' \
|
||||||
|
"$out/bin/cargo"
|
||||||
|
install_name_tool \
|
||||||
|
-change /usr/lib/libcurl.4.dylib '${getLib curl}/lib/libcurl.4.dylib' \
|
||||||
|
"$out/bin/cargo"
|
||||||
|
install_name_tool \
|
||||||
|
-change /usr/lib/libz.1.dylib '${getLib zlib}/lib/libz.1.dylib' \
|
||||||
|
"$out/bin/cargo"
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
|
||||||
installComponents
|
installComponents
|
||||||
= "rustc,rust-std-${platform}"
|
= "rustc,rust-std-${platform}"
|
||||||
+ (optionalString bootstrapping ",rust-docs,cargo")
|
+ (optionalString bootstrapping ",rust-docs,cargo")
|
||||||
@ -34,35 +54,31 @@ rec {
|
|||||||
license = [ licenses.mit licenses.asl20 ];
|
license = [ licenses.mit licenses.asl20 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
phases = ["unpackPhase" "installPhase"];
|
phases = ["unpackPhase" "installPhase" "fixupPhase"];
|
||||||
|
|
||||||
|
propagatedBuildInputs = stdenv.lib.optional stdenv.isDarwin Security;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
./install.sh --prefix=$out \
|
./install.sh --prefix=$out \
|
||||||
--components=${installComponents}
|
--components=${installComponents}
|
||||||
|
|
||||||
${optionalString (needsPatchelf && bootstrapping) ''
|
${optionalString (stdenv.isLinux && bootstrapping) ''
|
||||||
patchelf \
|
|
||||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
||||||
"$out/bin/rustdoc"
|
|
||||||
patchelf \
|
|
||||||
--set-rpath "${stdenv.lib.makeLibraryPath [ curl zlib ]}" \
|
|
||||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
||||||
"$out/bin/cargo"
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString needsPatchelf ''
|
|
||||||
patchelf \
|
patchelf \
|
||||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||||
"$out/bin/rustc"
|
"$out/bin/rustc"
|
||||||
|
patchelf \
|
||||||
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||||
|
"$out/bin/rustdoc"
|
||||||
|
''}
|
||||||
|
|
||||||
|
${patchBootstrapCargo}
|
||||||
|
|
||||||
# Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc
|
# Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc
|
||||||
# (or similar) here. It causes strange effects where rustc loads
|
# (or similar) here. It causes strange effects where rustc loads
|
||||||
# the wrong libraries in a bootstrap-build causing failures that
|
# the wrong libraries in a bootstrap-build causing failures that
|
||||||
# are very hard to track dow. For details, see
|
# are very hard to track dow. For details, see
|
||||||
# https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943
|
# https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943
|
||||||
''}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
cargo = stdenv.mkDerivation rec {
|
cargo = stdenv.mkDerivation rec {
|
||||||
@ -78,19 +94,16 @@ rec {
|
|||||||
license = [ licenses.mit licenses.asl20 ];
|
license = [ licenses.mit licenses.asl20 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
phases = ["unpackPhase" "installPhase" "fixupPhase"];
|
||||||
|
|
||||||
buildInputs = [ makeWrapper ];
|
buildInputs = [ makeWrapper ];
|
||||||
phases = ["unpackPhase" "installPhase"];
|
propagatedBuildInputs = stdenv.lib.optional stdenv.isDarwin Security;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
./install.sh --prefix=$out \
|
./install.sh --prefix=$out \
|
||||||
--components=cargo
|
--components=cargo
|
||||||
|
|
||||||
${optionalString needsPatchelf ''
|
${patchBootstrapCargo}
|
||||||
patchelf \
|
|
||||||
--set-rpath "${stdenv.lib.makeLibraryPath [ curl zlib ]}" \
|
|
||||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
||||||
"$out/bin/cargo"
|
|
||||||
''}
|
|
||||||
|
|
||||||
wrapProgram "$out/bin/cargo" \
|
wrapProgram "$out/bin/cargo" \
|
||||||
--suffix PATH : "${rustc}/bin"
|
--suffix PATH : "${rustc}/bin"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, fetchurl, makeWrapper, cacert, zlib, curl }:
|
{ stdenv, fetchurl, callPackage }:
|
||||||
|
|
||||||
let
|
let
|
||||||
# Note: the version MUST be one version prior to the version we're
|
# Note: the version MUST be one version prior to the version we're
|
||||||
@ -29,9 +29,8 @@ let
|
|||||||
sha256 = hashes."${platform}";
|
sha256 = hashes."${platform}";
|
||||||
};
|
};
|
||||||
|
|
||||||
in import ./binaryBuild.nix
|
in callPackage ./binaryBuild.nix
|
||||||
{ inherit stdenv fetchurl makeWrapper cacert zlib curl;
|
{ inherit version src platform;
|
||||||
buildRustPackage = null;
|
buildRustPackage = null;
|
||||||
inherit version src platform;
|
|
||||||
versionType = "bootstrap";
|
versionType = "bootstrap";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user