2018-11-21 01:47:45 +00:00
|
|
|
{ stdenv, makeWrapper, bash, curl, darwin
|
2017-05-30 14:48:06 +01:00
|
|
|
, version
|
|
|
|
, src
|
|
|
|
, platform
|
|
|
|
, versionType
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2018-07-20 20:36:12 +01:00
|
|
|
inherit (stdenv.lib) optionalString;
|
2017-11-01 14:37:04 +00:00
|
|
|
inherit (darwin.apple_sdk.frameworks) Security;
|
2017-05-30 14:48:06 +01:00
|
|
|
|
|
|
|
bootstrapping = versionType == "bootstrap";
|
|
|
|
|
|
|
|
installComponents
|
|
|
|
= "rustc,rust-std-${platform}"
|
2018-06-05 20:54:27 +01:00
|
|
|
+ (optionalString bootstrapping ",cargo")
|
2017-05-30 14:48:06 +01:00
|
|
|
;
|
|
|
|
in
|
|
|
|
|
|
|
|
rec {
|
|
|
|
rustc = stdenv.mkDerivation rec {
|
|
|
|
name = "rustc-${versionType}-${version}";
|
|
|
|
|
|
|
|
inherit version;
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = http://www.rust-lang.org/;
|
|
|
|
description = "A safe, concurrent, practical language";
|
|
|
|
maintainers = with maintainers; [ qknight ];
|
|
|
|
license = [ licenses.mit licenses.asl20 ];
|
|
|
|
};
|
|
|
|
|
2018-02-20 09:59:26 +00:00
|
|
|
buildInputs = [ bash ] ++ stdenv.lib.optional stdenv.isDarwin Security;
|
2017-05-30 14:48:06 +01:00
|
|
|
|
2018-02-20 09:59:26 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
2017-10-31 06:37:15 +00:00
|
|
|
|
2017-05-30 14:48:06 +01:00
|
|
|
installPhase = ''
|
|
|
|
./install.sh --prefix=$out \
|
|
|
|
--components=${installComponents}
|
|
|
|
|
2017-11-01 14:37:04 +00:00
|
|
|
${optionalString (stdenv.isLinux && bootstrapping) ''
|
2017-05-30 14:48:06 +01:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
2017-11-01 14:37:04 +00:00
|
|
|
"$out/bin/rustc"
|
2017-05-30 14:48:06 +01:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
2017-11-01 14:37:04 +00:00
|
|
|
"$out/bin/rustdoc"
|
2017-12-28 19:42:23 +00:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
|
|
"$out/bin/cargo"
|
2017-05-30 14:48:06 +01:00
|
|
|
''}
|
2017-12-28 19:42:23 +00:00
|
|
|
|
2017-10-31 06:37:15 +00:00
|
|
|
${optionalString (stdenv.isDarwin && bootstrapping) ''
|
2017-12-28 19:42:23 +00:00
|
|
|
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/rustc"
|
|
|
|
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/rustdoc"
|
2017-10-31 06:37:15 +00:00
|
|
|
install_name_tool -change /usr/lib/libiconv.2.dylib '${darwin.libiconv}/lib/libiconv.2.dylib' "$out/bin/cargo"
|
2017-12-28 19:42:23 +00:00
|
|
|
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/cargo"
|
2017-10-31 06:37:15 +00:00
|
|
|
install_name_tool -change /usr/lib/libcurl.4.dylib '${stdenv.lib.getLib curl}/lib/libcurl.4.dylib' "$out/bin/cargo"
|
2017-12-28 19:42:23 +00:00
|
|
|
for f in $out/lib/lib*.dylib; do
|
|
|
|
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$f"
|
|
|
|
done
|
2017-10-31 06:37:15 +00:00
|
|
|
''}
|
2017-05-30 14:48:06 +01:00
|
|
|
|
|
|
|
# Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc
|
|
|
|
# (or similar) here. It causes strange effects where rustc loads
|
|
|
|
# the wrong libraries in a bootstrap-build causing failures that
|
2018-06-13 00:01:24 +01:00
|
|
|
# are very hard to track down. For details, see
|
2017-05-30 14:48:06 +01:00
|
|
|
# https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
cargo = stdenv.mkDerivation rec {
|
|
|
|
name = "cargo-${versionType}-${version}";
|
|
|
|
|
|
|
|
inherit version;
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = http://www.rust-lang.org/;
|
|
|
|
description = "A safe, concurrent, practical language";
|
|
|
|
maintainers = with maintainers; [ qknight ];
|
|
|
|
license = [ licenses.mit licenses.asl20 ];
|
|
|
|
};
|
|
|
|
|
2018-02-20 09:59:26 +00:00
|
|
|
buildInputs = [ makeWrapper bash ] ++ stdenv.lib.optional stdenv.isDarwin Security;
|
2017-11-01 14:37:04 +00:00
|
|
|
|
2018-02-20 09:59:26 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
2017-05-30 14:48:06 +01:00
|
|
|
|
|
|
|
installPhase = ''
|
2018-02-03 11:57:57 +00:00
|
|
|
patchShebangs ./install.sh
|
2017-05-30 14:48:06 +01:00
|
|
|
./install.sh --prefix=$out \
|
|
|
|
--components=cargo
|
|
|
|
|
2017-12-28 19:42:23 +00:00
|
|
|
${optionalString (stdenv.isLinux && bootstrapping) ''
|
|
|
|
patchelf \
|
|
|
|
--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 '${darwin.libiconv}/lib/libiconv.2.dylib' "$out/bin/cargo"
|
|
|
|
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/cargo"
|
|
|
|
install_name_tool -change /usr/lib/libcurl.4.dylib '${stdenv.lib.getLib curl}/lib/libcurl.4.dylib' "$out/bin/cargo"
|
|
|
|
''}
|
2017-05-30 14:48:06 +01:00
|
|
|
|
|
|
|
wrapProgram "$out/bin/cargo" \
|
|
|
|
--suffix PATH : "${rustc}/bin"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|