72 lines
2.3 KiB
Nix
Raw Normal View History

{ stdenv, lib, runCommand, patchelf
2017-04-15 12:36:29 +02:00
, fetchFromGitHub, rustPlatform
2019-05-03 02:54:50 +08:00
, pkgconfig, curl, Security, CoreServices }:
2017-04-15 12:36:29 +02:00
rustPlatform.buildRustPackage rec {
2019-04-23 23:37:44 +08:00
pname = "rustup";
2019-10-16 20:01:49 +01:00
version = "1.20.2";
2017-04-15 12:36:29 +02:00
src = fetchFromGitHub {
2018-11-27 21:19:49 +02:00
owner = "rust-lang";
2017-04-15 12:36:29 +02:00
repo = "rustup.rs";
2018-02-20 22:42:18 +02:00
rev = version;
2019-10-16 20:01:49 +01:00
sha256 = "0vfrfjfg5x1g44w03rdci2ky7s3s7rljdcmmp5h6pdvhzrd234aj";
2017-04-15 12:36:29 +02:00
};
2019-10-15 11:40:21 +01:00
cargoSha256 = "1lsv1d99dn6mngaqhd3lw90cr3zg4gq08wi0adxkkhaikc9jjdwh";
2018-07-22 12:27:06 +03:00
2017-04-15 12:36:29 +02:00
nativeBuildInputs = [ pkgconfig ];
buildInputs = [
curl
2019-05-03 02:54:50 +08:00
] ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices Security ];
2017-04-15 12:36:29 +02:00
cargoBuildFlags = [ "--features no-self-update" ];
patches = lib.optionals stdenv.isLinux [
(runCommand "0001-dynamically-patchelf-binaries.patch" { CC=stdenv.cc; patchelf = patchelf; } ''
2017-04-15 12:36:29 +02:00
export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
--subst-var patchelf \
--subst-var dynamicLinker
2017-04-15 12:36:29 +02:00
'')
];
2019-05-23 10:55:11 +03:00
doCheck = !stdenv.isAarch64 && !stdenv.isDarwin;
2018-07-22 12:27:06 +03:00
2017-04-15 12:36:29 +02:00
postInstall = ''
pushd $out/bin
mv rustup-init rustup
2019-03-07 13:50:55 +02:00
binlinks=(
cargo rustc rustdoc rust-gdb rust-lldb rls rustfmt cargo-fmt
cargo-clippy clippy-driver cargo-miri
)
for link in ''${binlinks[@]}; do
2017-04-15 12:36:29 +02:00
ln -s rustup $link
done
popd
# tries to create .rustup
export HOME=$(mktemp -d)
2018-02-20 22:42:18 +02:00
mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions}
2019-04-23 23:37:44 +08:00
# 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"
2017-04-15 12:36:29 +02:00
'';
meta = with stdenv.lib; {
description = "The Rust toolchain installer";
homepage = https://www.rustup.rs/;
2018-02-20 22:42:18 +02:00
license = with licenses; [ asl20 /* or */ mit ];
maintainers = [ maintainers.mic92 ];
2019-05-23 10:55:11 +03:00
platforms = platforms.all;
2017-04-15 12:36:29 +02:00
};
}