rustup: refactor (#400028)
This commit is contained in:
@@ -9,11 +9,14 @@
|
||||
pkg-config,
|
||||
openssl,
|
||||
curl,
|
||||
writableTmpDirAsHomeHook,
|
||||
installShellFiles,
|
||||
zlib,
|
||||
Security,
|
||||
CoreServices,
|
||||
libiconv,
|
||||
xz,
|
||||
buildPackages,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -22,15 +25,15 @@ let
|
||||
];
|
||||
in
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
rustPlatform.buildRustPackage (finalAttrs: {
|
||||
pname = "rustup";
|
||||
version = "1.27.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "rust-lang";
|
||||
repo = "rustup";
|
||||
rev = version;
|
||||
sha256 = "sha256-BehkJTEIbZHaM+ABaWN/grl9pX75lPqyBj1q1Kt273M=";
|
||||
tag = finalAttrs.version;
|
||||
hash = "sha256-BehkJTEIbZHaM+ABaWN/grl9pX75lPqyBj1q1Kt273M=";
|
||||
};
|
||||
|
||||
useFetchCargoVendor = true;
|
||||
@@ -39,11 +42,14 @@ rustPlatform.buildRustPackage rec {
|
||||
nativeBuildInputs = [
|
||||
makeBinaryWrapper
|
||||
pkg-config
|
||||
writableTmpDirAsHomeHook
|
||||
installShellFiles
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
[
|
||||
(curl.override { inherit openssl; })
|
||||
openssl
|
||||
curl
|
||||
zlib
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
@@ -103,18 +109,26 @@ rustPlatform.buildRustPackage rec {
|
||||
wrapProgram $out/bin/rustup --prefix "LD_LIBRARY_PATH" : "${libPath}"
|
||||
|
||||
# tries to create .rustup
|
||||
export HOME=$(mktemp -d)
|
||||
mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions}
|
||||
|
||||
# generate completion scripts for rustup
|
||||
$out/bin/rustup completions bash rustup > "$out/share/bash-completion/completions/rustup"
|
||||
$out/bin/rustup completions fish rustup > "$out/share/fish/vendor_completions.d/rustup.fish"
|
||||
$out/bin/rustup completions zsh rustup > "$out/share/zsh/site-functions/_rustup"
|
||||
${lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
|
||||
let
|
||||
emulator = stdenv.hostPlatform.emulator buildPackages;
|
||||
in
|
||||
''
|
||||
# generate completion scripts for rustup
|
||||
installShellCompletion --cmd rustup \
|
||||
--bash <(${emulator} $out/bin/rustup completions bash rustup) \
|
||||
--fish <(${emulator} $out/bin/rustup completions fish rustup) \
|
||||
--zsh <(${emulator} $out/bin/rustup completions zsh rustup)
|
||||
|
||||
# generate completion scripts for cargo
|
||||
# Note: fish completion script is not supported.
|
||||
$out/bin/rustup completions bash cargo > "$out/share/bash-completion/completions/cargo"
|
||||
$out/bin/rustup completions zsh cargo > "$out/share/zsh/site-functions/_cargo"
|
||||
# generate completion scripts for cargo
|
||||
# Note: fish completion script is not supported.
|
||||
installShellCompletion --cmd cargo \
|
||||
--bash <(${emulator} $out/bin/rustup completions bash cargo) \
|
||||
--zsh <(${emulator} $out/bin/rustup completions zsh cargo)
|
||||
''
|
||||
)}
|
||||
|
||||
# add a wrapper script for ld.lld
|
||||
mkdir -p $out/nix-support
|
||||
@@ -128,7 +142,7 @@ rustPlatform.buildRustPackage rec {
|
||||
chmod +x $out/nix-support/ld-wrapper.sh
|
||||
'';
|
||||
|
||||
env = lib.optionalAttrs (pname == "rustup") {
|
||||
env = {
|
||||
inherit (stdenv.cc.bintools)
|
||||
expandResponseParams
|
||||
shell
|
||||
@@ -139,13 +153,16 @@ rustPlatform.buildRustPackage rec {
|
||||
hardening_unsupported_flags = "";
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
meta = {
|
||||
description = "Rust toolchain installer";
|
||||
homepage = "https://www.rustup.rs/";
|
||||
license = with licenses; [
|
||||
license = with lib.licenses; [
|
||||
asl20 # or
|
||||
mit
|
||||
];
|
||||
maintainers = [ maintainers.mic92 ];
|
||||
maintainers = with lib.maintainers; [
|
||||
mic92
|
||||
];
|
||||
mainProgram = "rustup";
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user