nixpkgs/pkgs/development/compilers/rust/binary.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

97 lines
2.6 KiB
Nix
Raw Normal View History

{ lib, stdenv, makeWrapper, bash, curl, darwin, zlib
, autoPatchelfHook, gcc
, version
, src
, platform
, versionType
}:
let
inherit (lib) optionalString;
inherit (darwin.apple_sdk.frameworks) Security;
bootstrapping = versionType == "bootstrap";
installComponents
= "rustc,rust-std-${platform}"
2018-06-05 19:54:27 +00:00
+ (optionalString bootstrapping ",cargo")
;
in
rec {
2019-08-13 21:52:01 +00:00
rustc = stdenv.mkDerivation {
2022-03-01 10:53:13 +00:00
pname = "rustc-${versionType}";
inherit version;
inherit src;
meta = with lib; {
homepage = "http://www.rust-lang.org/";
description = "A safe, concurrent, practical language";
maintainers = with maintainers; [ qknight ];
license = [ licenses.mit licenses.asl20 ];
};
nativeBuildInputs = lib.optional (!stdenv.isDarwin) autoPatchelfHook;
buildInputs = [ bash ]
++ lib.optionals (!stdenv.isDarwin) [ gcc.cc.lib zlib ]
++ lib.optional stdenv.isDarwin Security;
2018-02-20 09:59:26 +00:00
postPatch = ''
patchShebangs .
'';
2017-10-31 06:37:15 +00:00
installPhase = ''
./install.sh --prefix=$out \
--components=${installComponents}
# 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
'';
2019-08-15 15:50:28 +00:00
2022-10-19 20:51:27 +00:00
# The strip tool in cctools 973.0.1 and up appears to break rlibs in the
# binaries. The lib.rmeta object inside the ar archive should contain an
# .rmeta section, but it is removed. Luckily, this doesn't appear to be an
# issue for Rust builds produced by Nix.
dontStrip = stdenv.isDarwin;
2019-08-15 15:50:28 +00:00
setupHooks = ./setup-hook.sh;
};
2019-08-13 21:52:01 +00:00
cargo = stdenv.mkDerivation {
2022-03-01 10:53:13 +00:00
pname = "cargo-${versionType}";
inherit version;
inherit src;
meta = with lib; {
homepage = "http://www.rust-lang.org/";
description = "A safe, concurrent, practical language";
maintainers = with maintainers; [ qknight ];
license = [ licenses.mit licenses.asl20 ];
};
nativeBuildInputs = [ makeWrapper ]
++ lib.optional (!stdenv.isDarwin) autoPatchelfHook;
buildInputs = [ bash ]
++ lib.optional (!stdenv.isDarwin) gcc.cc.lib
++ lib.optional stdenv.isDarwin Security;
2018-02-20 09:59:26 +00:00
postPatch = ''
patchShebangs .
'';
installPhase = ''
patchShebangs ./install.sh
./install.sh --prefix=$out \
--components=cargo
wrapProgram "$out/bin/cargo" \
--suffix PATH : "${rustc}/bin"
'';
};
}