1{ stdenv, lib, runCommand, patchelf
2, fetchFromGitHub, rustPlatform
3, pkgconfig, curl, Security }:
4
5rustPlatform.buildRustPackage rec {
6 name = "rustup-${version}";
7 version = "1.13.0";
8
9 src = fetchFromGitHub {
10 owner = "rust-lang-nursery";
11 repo = "rustup.rs";
12 rev = version;
13 sha256 = "1h0786jx64nc9q8x6fv7a5sf1xijxhn02m2pq5v2grl9ks0vxidn";
14 };
15
16 cargoSha256 = "09lbm2k189sri3vwcwzv7j07ah39c8ajbpkg0kzvjsjwr7ypli8a";
17
18 nativeBuildInputs = [ pkgconfig ];
19
20 buildInputs = [
21 curl
22 ] ++ stdenv.lib.optionals stdenv.isDarwin [ Security ];
23
24 cargoBuildFlags = [ "--features no-self-update" ];
25
26 patches = lib.optionals stdenv.isLinux [
27 (runCommand "0001-dynamically-patchelf-binaries.patch" { CC=stdenv.cc; patchelf = patchelf; } ''
28 export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
29 substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
30 --subst-var patchelf \
31 --subst-var dynamicLinker
32 '')
33 ];
34
35 doCheck = !stdenv.isAarch64;
36
37 postInstall = ''
38 pushd $out/bin
39 mv rustup-init rustup
40 for link in cargo rustc rustdoc rust-gdb rust-lldb rls rustfmt cargo-fmt cargo-clippy; do
41 ln -s rustup $link
42 done
43 popd
44
45 # tries to create .rustup
46 export HOME=$(mktemp -d)
47 mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions}
48 $out/bin/rustup completions bash > "$out/share/bash-completion/completions/rustup"
49 $out/bin/rustup completions fish > "$out/share/fish/vendor_completions.d/rustup.fish"
50 $out/bin/rustup completions zsh > "$out/share/zsh/site-functions/_rustup"
51 '';
52
53 meta = with stdenv.lib; {
54 description = "The Rust toolchain installer";
55 homepage = https://www.rustup.rs/;
56 license = with licenses; [ asl20 /* or */ mit ];
57 maintainers = [ maintainers.mic92 ];
58 };
59}