2017-10-29 20:32:40 +00:00
|
|
|
{ stdenv, lib, runCommand, patchelf
|
2020-08-31 18:49:52 +01:00
|
|
|
, fetchFromGitHub, rustPlatform, makeWrapper
|
2021-01-19 06:50:56 +00:00
|
|
|
, pkg-config, curl, zlib, Security, CoreServices }:
|
2017-04-15 11:36:29 +01:00
|
|
|
|
2020-08-31 18:49:52 +01:00
|
|
|
let
|
|
|
|
libPath = lib.makeLibraryPath [
|
|
|
|
zlib # libz.so.1
|
|
|
|
];
|
|
|
|
in
|
|
|
|
|
2017-04-15 11:36:29 +01:00
|
|
|
rustPlatform.buildRustPackage rec {
|
2019-04-23 16:37:44 +01:00
|
|
|
pname = "rustup";
|
2020-12-09 12:49:11 +00:00
|
|
|
version = "1.23.1";
|
2017-04-15 11:36:29 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2018-11-27 19:19:49 +00:00
|
|
|
owner = "rust-lang";
|
2019-12-20 13:05:38 +00:00
|
|
|
repo = "rustup";
|
2018-02-20 20:42:18 +00:00
|
|
|
rev = version;
|
2020-12-09 12:49:11 +00:00
|
|
|
sha256 = "1i3ipkq6j47bf9dh9j3axzj6z443jm4j651g38cxyrrx8b2s15x0";
|
2017-04-15 11:36:29 +01:00
|
|
|
};
|
|
|
|
|
2020-12-09 12:49:11 +00:00
|
|
|
cargoSha256 = "1zkrrg5m0j9rk65g51v2zh404529p9z84qqb7bfyjmgiqlnh48ig";
|
2018-07-22 10:27:06 +01:00
|
|
|
|
2021-01-19 06:50:56 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper pkg-config ];
|
2017-04-15 11:36:29 +01:00
|
|
|
|
|
|
|
buildInputs = [
|
2020-06-23 01:18:42 +01:00
|
|
|
curl zlib
|
2021-01-23 12:26:19 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [ CoreServices Security ];
|
2017-04-15 11:36:29 +01:00
|
|
|
|
|
|
|
cargoBuildFlags = [ "--features no-self-update" ];
|
|
|
|
|
|
|
|
patches = lib.optionals stdenv.isLinux [
|
2020-08-31 18:49:52 +01: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
|
2017-04-15 11:36:29 +01:00
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2020-07-14 13:39:13 +01:00
|
|
|
doCheck = !stdenv.isAarch64 && !stdenv.isDarwin;
|
2018-07-22 10:27:06 +01:00
|
|
|
|
2017-04-15 11:36:29 +01:00
|
|
|
postInstall = ''
|
|
|
|
pushd $out/bin
|
|
|
|
mv rustup-init rustup
|
2019-03-07 11:50:55 +00: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 11:36:29 +01:00
|
|
|
ln -s rustup $link
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
|
2020-08-31 18:49:52 +01:00
|
|
|
wrapProgram $out/bin/rustup --prefix "LD_LIBRARY_PATH" : "${libPath}"
|
|
|
|
|
2017-04-15 11:36:29 +01:00
|
|
|
# tries to create .rustup
|
|
|
|
export HOME=$(mktemp -d)
|
2018-02-20 20:42:18 +00:00
|
|
|
mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions}
|
2019-04-23 16:37:44 +01: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 11:36:29 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2017-04-15 11:36:29 +01:00
|
|
|
description = "The Rust toolchain installer";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://www.rustup.rs/";
|
2018-02-20 20:42:18 +00:00
|
|
|
license = with licenses; [ asl20 /* or */ mit ];
|
2017-12-05 22:20:11 +00:00
|
|
|
maintainers = [ maintainers.mic92 ];
|
2017-04-15 11:36:29 +01:00
|
|
|
};
|
|
|
|
}
|