Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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.26.0"; 27 28 src = fetchFromGitHub { 29 owner = "rust-lang"; 30 repo = "rustup"; 31 rev = version; 32 sha256 = "sha256-rdhG9MdjWyvoaMGdjgFyCfQaoV48QtAZE7buA5TkDKg="; 33 }; 34 35 cargoLock = { 36 lockFile = ./Cargo.lock; 37 }; 38 39 nativeBuildInputs = [ makeBinaryWrapper pkg-config ]; 40 41 buildInputs = [ 42 (curl.override { inherit openssl; }) 43 zlib 44 ] ++ lib.optionals stdenv.isDarwin [ CoreServices Security libiconv xz ]; 45 46 buildFeatures = [ "no-self-update" ]; 47 48 checkFeatures = [ ]; 49 50 patches = lib.optionals stdenv.isLinux [ 51 (runCommand "0001-dynamically-patchelf-binaries.patch" { CC = stdenv.cc; patchelf = patchelf; libPath = "$ORIGIN/../lib:${libPath}"; } '' 52 export dynamicLinker=$(cat $CC/nix-support/dynamic-linker) 53 substitute ${./0001-dynamically-patchelf-binaries.patch} $out \ 54 --subst-var patchelf \ 55 --subst-var dynamicLinker \ 56 --subst-var libPath 57 '') 58 ]; 59 60 doCheck = !stdenv.isAarch64 && !stdenv.isDarwin; 61 62 # skip failing tests 63 checkFlags = [ 64 # auto-self-update mode is set to 'disable' for nix rustup 65 "--skip=suite::cli_exact::check_updates_none" 66 "--skip=suite::cli_exact::check_updates_some" 67 "--skip=suite::cli_exact::check_updates_with_update" 68 # rustup-init is not used in nix rustup 69 "--skip=suite::cli_ui::rustup_init_ui_doc_text_tests" 70 ]; 71 72 postInstall = '' 73 pushd $out/bin 74 mv rustup-init rustup 75 binlinks=( 76 cargo rustc rustdoc rust-gdb rust-lldb rls rustfmt cargo-fmt 77 cargo-clippy clippy-driver cargo-miri rust-gdbgui rust-analyzer 78 ) 79 for link in ''${binlinks[@]}; do 80 ln -s rustup $link 81 done 82 popd 83 84 wrapProgram $out/bin/rustup --prefix "LD_LIBRARY_PATH" : "${libPath}" 85 86 # tries to create .rustup 87 export HOME=$(mktemp -d) 88 mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions} 89 90 # generate completion scripts for rustup 91 $out/bin/rustup completions bash rustup > "$out/share/bash-completion/completions/rustup" 92 $out/bin/rustup completions fish rustup > "$out/share/fish/vendor_completions.d/rustup.fish" 93 $out/bin/rustup completions zsh rustup > "$out/share/zsh/site-functions/_rustup" 94 95 # generate completion scripts for cargo 96 # Note: fish completion script is not supported. 97 $out/bin/rustup completions bash cargo > "$out/share/bash-completion/completions/cargo" 98 $out/bin/rustup completions zsh cargo > "$out/share/zsh/site-functions/_cargo" 99 ''; 100 101 meta = with lib; { 102 description = "The Rust toolchain installer"; 103 homepage = "https://www.rustup.rs/"; 104 license = with licenses; [ asl20 /* or */ mit ]; 105 maintainers = [ maintainers.mic92 ]; 106 }; 107}