2018-11-21 02:47:45 +01:00
|
|
|
{ stdenv, makeWrapper, bash, curl, darwin
|
2017-05-30 15:48:06 +02:00
|
|
|
, version
|
|
|
|
, src
|
|
|
|
, platform
|
|
|
|
, versionType
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2018-07-20 21:36:12 +02:00
|
|
|
inherit (stdenv.lib) optionalString;
|
2017-11-01 15:37:04 +01:00
|
|
|
inherit (darwin.apple_sdk.frameworks) Security;
|
2017-05-30 15:48:06 +02:00
|
|
|
|
|
|
|
bootstrapping = versionType == "bootstrap";
|
|
|
|
|
|
|
|
installComponents
|
|
|
|
= "rustc,rust-std-${platform}"
|
2018-06-05 21:54:27 +02:00
|
|
|
+ (optionalString bootstrapping ",cargo")
|
2017-05-30 15:48:06 +02:00
|
|
|
;
|
|
|
|
in
|
|
|
|
|
|
|
|
rec {
|
2019-08-13 23:52:01 +02:00
|
|
|
rustc = stdenv.mkDerivation {
|
2017-05-30 15:48:06 +02:00
|
|
|
name = "rustc-${versionType}-${version}";
|
|
|
|
|
|
|
|
inherit version;
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "http://www.rust-lang.org/";
|
2017-05-30 15:48:06 +02:00
|
|
|
description = "A safe, concurrent, practical language";
|
|
|
|
maintainers = with maintainers; [ qknight ];
|
|
|
|
license = [ licenses.mit licenses.asl20 ];
|
|
|
|
};
|
|
|
|
|
2019-06-28 20:42:12 +02:00
|
|
|
buildInputs = [ bash ]
|
|
|
|
++ stdenv.lib.optional stdenv.isDarwin Security;
|
2017-05-30 15:48:06 +02:00
|
|
|
|
2018-02-20 10:59:26 +01:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
2017-10-31 07:37:15 +01:00
|
|
|
|
2017-05-30 15:48:06 +02:00
|
|
|
installPhase = ''
|
|
|
|
./install.sh --prefix=$out \
|
|
|
|
--components=${installComponents}
|
|
|
|
|
2017-11-01 15:37:04 +01:00
|
|
|
${optionalString (stdenv.isLinux && bootstrapping) ''
|
2017-05-30 15:48:06 +02:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
2017-11-01 15:37:04 +01:00
|
|
|
"$out/bin/rustc"
|
2017-05-30 15:48:06 +02:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
2017-11-01 15:37:04 +01:00
|
|
|
"$out/bin/rustdoc"
|
2017-12-28 20:42:23 +01:00
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
|
|
"$out/bin/cargo"
|
2017-05-30 15:48:06 +02:00
|
|
|
''}
|
2017-12-28 20:42:23 +01:00
|
|
|
|
2017-05-30 15:48:06 +02: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 01:01:24 +02:00
|
|
|
# are very hard to track down. For details, see
|
2017-05-30 15:48:06 +02:00
|
|
|
# https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943
|
|
|
|
'';
|
2019-08-15 17:50:28 +02:00
|
|
|
|
|
|
|
setupHooks = ./setup-hook.sh;
|
2017-05-30 15:48:06 +02:00
|
|
|
};
|
|
|
|
|
2019-08-13 23:52:01 +02:00
|
|
|
cargo = stdenv.mkDerivation {
|
2017-05-30 15:48:06 +02:00
|
|
|
name = "cargo-${versionType}-${version}";
|
|
|
|
|
|
|
|
inherit version;
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "http://www.rust-lang.org/";
|
2017-05-30 15:48:06 +02:00
|
|
|
description = "A safe, concurrent, practical language";
|
|
|
|
maintainers = with maintainers; [ qknight ];
|
|
|
|
license = [ licenses.mit licenses.asl20 ];
|
|
|
|
};
|
|
|
|
|
2019-06-28 20:42:12 +02:00
|
|
|
buildInputs = [ makeWrapper bash ]
|
|
|
|
++ stdenv.lib.optional stdenv.isDarwin Security;
|
2017-11-01 15:37:04 +01:00
|
|
|
|
2018-02-20 10:59:26 +01:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
2017-05-30 15:48:06 +02:00
|
|
|
|
|
|
|
installPhase = ''
|
2018-02-03 12:57:57 +01:00
|
|
|
patchShebangs ./install.sh
|
2017-05-30 15:48:06 +02:00
|
|
|
./install.sh --prefix=$out \
|
|
|
|
--components=cargo
|
|
|
|
|
2017-12-28 20:42:23 +01:00
|
|
|
${optionalString (stdenv.isLinux && bootstrapping) ''
|
|
|
|
patchelf \
|
|
|
|
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
|
|
"$out/bin/cargo"
|
|
|
|
''}
|
|
|
|
|
2017-05-30 15:48:06 +02:00
|
|
|
wrapProgram "$out/bin/cargo" \
|
|
|
|
--suffix PATH : "${rustc}/bin"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|