nixpkgs/pkgs/development/compilers/rust/binary.nix
Vladimír Čunát 89023c38fc
Recover the complicated situation after my bad merge
I made a mistake merge.  Reverting it in c778945806 undid the state
on master, but now I realize it crippled the git merge mechanism.
As the merge contained a mix of commits from `master..staging-next`
and other commits from `staging-next..staging`, it got the
`staging-next` branch into a state that was difficult to recover.

I reconstructed the "desired" state of staging-next tree by:
 - checking out the last commit of the problematic range: 4effe769e2
 - `git rebase -i --preserve-merges a8a018ddc0` - dropping the mistaken
   merge commit and its revert from that range (while keeping
   reapplication from 4effe769e2)
 - merging the last unaffected staging-next commit (803ca85c20)
 - fortunately no other commits have been pushed to staging-next yet
 - applying a diff on staging-next to get it into that state
2020-10-26 09:01:04 +01:00

109 lines
2.9 KiB
Nix

{ stdenv, makeWrapper, bash, curl, darwin, zlib
, version
, src
, platform
, versionType
}:
let
inherit (stdenv.lib) optionalString;
inherit (darwin.apple_sdk.frameworks) Security;
bootstrapping = versionType == "bootstrap";
installComponents
= "rustc,rust-std-${platform}"
+ (optionalString bootstrapping ",cargo")
;
in
rec {
rustc = stdenv.mkDerivation {
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 ];
};
buildInputs = [ bash ]
++ stdenv.lib.optional stdenv.isDarwin Security;
postPatch = ''
patchShebangs .
'';
installPhase = ''
./install.sh --prefix=$out \
--components=${installComponents}
${optionalString (stdenv.isLinux && bootstrapping) (''
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
"$out/bin/rustc"
'' + optionalString (stdenv.lib.versionAtLeast version "1.46")
# rustc bootstrap needs libz starting from 1.46
''
ln -s ${zlib}/lib/libz.so.1 $out/lib/libz.so.1
ln -s ${zlib}/lib/libz.so $out/lib/libz.so
'' + ''
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
"$out/bin/rustdoc"
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
"$out/bin/cargo"
'')}
# 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
# are very hard to track down. For details, see
# https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943
'';
setupHooks = ./setup-hook.sh;
};
cargo = stdenv.mkDerivation {
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 ];
};
buildInputs = [ makeWrapper bash ]
++ stdenv.lib.optional stdenv.isDarwin Security;
postPatch = ''
patchShebangs .
'';
installPhase = ''
patchShebangs ./install.sh
./install.sh --prefix=$out \
--components=cargo
${optionalString (stdenv.isLinux && bootstrapping) ''
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
"$out/bin/cargo"
''}
wrapProgram "$out/bin/cargo" \
--suffix PATH : "${rustc}/bin"
'';
};
}