at 23.05-pre 95 lines 2.6 kB view raw
1{ stdenv 2, lib 3, runCommand 4, patchelf 5, fetchFromGitHub 6, rustPlatform 7, makeBinaryWrapper 8, pkg-config 9, openssl 10, curl 11, zlib 12, Security 13, CoreServices 14, libiconv 15, xz 16}: 17 18let 19 libPath = lib.makeLibraryPath [ 20 zlib # libz.so.1 21 ]; 22in 23 24rustPlatform.buildRustPackage rec { 25 pname = "rustup"; 26 version = "1.25.1"; 27 28 src = fetchFromGitHub { 29 owner = "rust-lang"; 30 repo = "rustup"; 31 rev = version; 32 sha256 = "sha256-zCr8xu0j/pBsdJEAYTCGrEouA8QumBnyhM4YLFZJqZI="; 33 }; 34 35 cargoSha256 = "sha256-FDVZn2PjqxovQmmandJICkidurhoXCAxo3bibuxQSMY="; 36 37 nativeBuildInputs = [ makeBinaryWrapper pkg-config ]; 38 39 buildInputs = [ 40 (curl.override { inherit openssl; }) 41 zlib 42 ] ++ lib.optionals stdenv.isDarwin [ CoreServices Security libiconv xz ]; 43 44 buildFeatures = [ "no-self-update" ]; 45 46 checkFeatures = [ ]; 47 48 patches = lib.optionals stdenv.isLinux [ 49 (runCommand "0001-dynamically-patchelf-binaries.patch" { CC = stdenv.cc; patchelf = patchelf; libPath = "$ORIGIN/../lib:${libPath}"; } '' 50 export dynamicLinker=$(cat $CC/nix-support/dynamic-linker) 51 substitute ${./0001-dynamically-patchelf-binaries.patch} $out \ 52 --subst-var patchelf \ 53 --subst-var dynamicLinker \ 54 --subst-var libPath 55 '') 56 ]; 57 58 doCheck = !stdenv.isAarch64 && !stdenv.isDarwin; 59 60 postInstall = '' 61 pushd $out/bin 62 mv rustup-init rustup 63 binlinks=( 64 cargo rustc rustdoc rust-gdb rust-lldb rls rustfmt cargo-fmt 65 cargo-clippy clippy-driver cargo-miri rust-gdbgui 66 ) 67 for link in ''${binlinks[@]}; do 68 ln -s rustup $link 69 done 70 popd 71 72 wrapProgram $out/bin/rustup --prefix "LD_LIBRARY_PATH" : "${libPath}" 73 74 # tries to create .rustup 75 export HOME=$(mktemp -d) 76 mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions} 77 78 # generate completion scripts for rustup 79 $out/bin/rustup completions bash rustup > "$out/share/bash-completion/completions/rustup" 80 $out/bin/rustup completions fish rustup > "$out/share/fish/vendor_completions.d/rustup.fish" 81 $out/bin/rustup completions zsh rustup > "$out/share/zsh/site-functions/_rustup" 82 83 # generate completion scripts for cargo 84 # Note: fish completion script is not supported. 85 $out/bin/rustup completions bash cargo > "$out/share/bash-completion/completions/cargo" 86 $out/bin/rustup completions zsh cargo > "$out/share/zsh/site-functions/_cargo" 87 ''; 88 89 meta = with lib; { 90 description = "The Rust toolchain installer"; 91 homepage = "https://www.rustup.rs/"; 92 license = with licenses; [ asl20 /* or */ mit ]; 93 maintainers = [ maintainers.mic92 ]; 94 }; 95}