biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / rust / rustup / default.nix
blobe5874580d3f90f2d0ec30d1b98edd4fb8b0ae022
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
18 let
19   libPath = lib.makeLibraryPath [
20     zlib # libz.so.1
21   ];
24 rustPlatform.buildRustPackage rec {
25   pname = "rustup";
26   version = "1.26.0";
28   src = fetchFromGitHub {
29     owner = "rust-lang";
30     repo = "rustup";
31     rev = version;
32     sha256 = "sha256-rdhG9MdjWyvoaMGdjgFyCfQaoV48QtAZE7buA5TkDKg=";
33   };
35   cargoLock = {
36     lockFile = ./Cargo.lock;
37   };
39   nativeBuildInputs = [ makeBinaryWrapper pkg-config ];
41   buildInputs = [
42     (curl.override { inherit openssl; })
43     zlib
44   ] ++ lib.optionals stdenv.isDarwin [ CoreServices Security libiconv xz ];
46   buildFeatures = [ "no-self-update" ];
48   checkFeatures = [ ];
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   ];
60   doCheck = !stdenv.isAarch64 && !stdenv.isDarwin;
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   ];
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
84     wrapProgram $out/bin/rustup --prefix "LD_LIBRARY_PATH" : "${libPath}"
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}
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"
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   '';
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   };