2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv, lib, runCommand, patchelf
|
2020-09-25 04:45:31 +00:00
|
|
|
, fetchFromGitHub, rustPlatform, makeWrapper
|
2020-07-18 16:06:22 +00:00
|
|
|
, pkgconfig, curl, zlib, Security, CoreServices }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
let
|
|
|
|
libPath = lib.makeLibraryPath [
|
|
|
|
zlib # libz.so.1
|
|
|
|
];
|
|
|
|
in
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "rustup";
|
2020-07-18 16:06:22 +00:00
|
|
|
version = "1.22.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "rust-lang";
|
|
|
|
repo = "rustup";
|
|
|
|
rev = version;
|
2020-07-18 16:06:22 +00:00
|
|
|
sha256 = "0nf42pkyn87y0n93vd63bihx74h4bpisv74aqldg3vcav2iv35s1";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
cargoSha256 = "0ghjrx7y25s6rjp06h0iyv4195x7daj57bqza01i1j4hm5nkhqhi";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper pkgconfig ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
2020-07-18 16:06:22 +00:00
|
|
|
curl zlib
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices Security ];
|
|
|
|
|
|
|
|
cargoBuildFlags = [ "--features no-self-update" ];
|
|
|
|
|
|
|
|
patches = lib.optionals stdenv.isLinux [
|
2020-09-25 04:45:31 +00:00
|
|
|
(runCommand "0001-dynamically-patchelf-binaries.patch" { CC=stdenv.cc; patchelf = patchelf; libPath = "$ORIGIN/../lib:${libPath}"; } ''
|
|
|
|
export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
|
|
|
|
substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
|
|
|
|
--subst-var patchelf \
|
|
|
|
--subst-var dynamicLinker \
|
|
|
|
--subst-var libPath
|
2020-04-24 23:36:52 +00:00
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
doCheck = !stdenv.isAarch64 && !stdenv.isDarwin;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
pushd $out/bin
|
|
|
|
mv rustup-init rustup
|
|
|
|
binlinks=(
|
|
|
|
cargo rustc rustdoc rust-gdb rust-lldb rls rustfmt cargo-fmt
|
|
|
|
cargo-clippy clippy-driver cargo-miri
|
|
|
|
)
|
|
|
|
for link in ''${binlinks[@]}; do
|
|
|
|
ln -s rustup $link
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
wrapProgram $out/bin/rustup --prefix "LD_LIBRARY_PATH" : "${libPath}"
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# tries to create .rustup
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions}
|
|
|
|
|
|
|
|
# generate completion scripts for rustup
|
|
|
|
$out/bin/rustup completions bash rustup > "$out/share/bash-completion/completions/rustup"
|
|
|
|
$out/bin/rustup completions fish rustup > "$out/share/fish/vendor_completions.d/rustup.fish"
|
|
|
|
$out/bin/rustup completions zsh rustup > "$out/share/zsh/site-functions/_rustup"
|
|
|
|
|
|
|
|
# generate completion scripts for cargo
|
|
|
|
# Note: fish completion script is not supported.
|
|
|
|
$out/bin/rustup completions bash cargo > "$out/share/bash-completion/completions/cargo"
|
|
|
|
$out/bin/rustup completions zsh cargo > "$out/share/zsh/site-functions/_cargo"
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "The Rust toolchain installer";
|
|
|
|
homepage = "https://www.rustup.rs/";
|
|
|
|
license = with licenses; [ asl20 /* or */ mit ];
|
|
|
|
maintainers = [ maintainers.mic92 ];
|
|
|
|
};
|
|
|
|
}
|