nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 20.03 71 lines 2.3 kB view raw
1{ stdenv, lib, runCommand, patchelf 2, fetchFromGitHub, rustPlatform 3, pkgconfig, curl, Security, CoreServices }: 4 5rustPlatform.buildRustPackage rec { 6 pname = "rustup"; 7 version = "1.21.1"; 8 9 src = fetchFromGitHub { 10 owner = "rust-lang"; 11 repo = "rustup"; 12 rev = version; 13 sha256 = "0d7l3j8js16zgdx37kykavr343v65vchldz88j38jjyc43pcm2pg"; 14 }; 15 16 cargoSha256 = "0kn3sq99sgsh8msignyb4vjllv0wf1crqaw7sqp3ggmlkrdq35sd"; 17 18 nativeBuildInputs = [ pkgconfig ]; 19 20 buildInputs = [ 21 curl 22 ] ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices 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 && !stdenv.isDarwin; 36 37 postInstall = '' 38 pushd $out/bin 39 mv rustup-init rustup 40 binlinks=( 41 cargo rustc rustdoc rust-gdb rust-lldb rls rustfmt cargo-fmt 42 cargo-clippy clippy-driver cargo-miri 43 ) 44 for link in ''${binlinks[@]}; do 45 ln -s rustup $link 46 done 47 popd 48 49 # tries to create .rustup 50 export HOME=$(mktemp -d) 51 mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions} 52 53 # generate completion scripts for rustup 54 $out/bin/rustup completions bash rustup > "$out/share/bash-completion/completions/rustup" 55 $out/bin/rustup completions fish rustup > "$out/share/fish/vendor_completions.d/rustup.fish" 56 $out/bin/rustup completions zsh rustup > "$out/share/zsh/site-functions/_rustup" 57 58 # generate completion scripts for cargo 59 # Note: fish completion script is not supported. 60 $out/bin/rustup completions bash cargo > "$out/share/bash-completion/completions/cargo" 61 $out/bin/rustup completions zsh cargo > "$out/share/zsh/site-functions/_cargo" 62 ''; 63 64 meta = with stdenv.lib; { 65 description = "The Rust toolchain installer"; 66 homepage = https://www.rustup.rs/; 67 license = with licenses; [ asl20 /* or */ mit ]; 68 maintainers = [ maintainers.mic92 ]; 69 platforms = platforms.all; 70 }; 71}