feat: Add rustup installer

This commit is contained in:
2026-06-20 14:10:53 +05:30
parent a2a388a81b
commit 5312189ed1
4 changed files with 86 additions and 2 deletions

View File

@@ -1 +1 @@
1.0.4
1.0.5

View File

@@ -0,0 +1,82 @@
#!/usr/bin/env bash
#
# Rust Installer Script
#
# Run metascript to check if the shell is bash and load libraries
PARENT_DIR="$(dirname "$0")/.."
METASCRIPT_LOCAL="$PARENT_DIR/bootstrap.sh"
METASCRIPT_URL="https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/bootstrap.sh"
if [ -f "$METASCRIPT_LOCAL" ]; then
. "$METASCRIPT_LOCAL"
else
if command -v wget >/dev/null 2>&1; then
eval "$(wget -qO- "$METASCRIPT_URL")"
elif command -v curl >/dev/null 2>&1; then
eval "$(curl -fsSL "$METASCRIPT_URL")"
else
echo "Error: Neither wget nor curl is installed to fetch bootstrap.sh." >&2
exit 1
fi
fi
set -euo pipefail
install_curl() {
if ! has_command curl; then
log_info "curl not found. Installing curl..."
pkg_install curl
fi
}
install_rust() {
if has_command rustup || [ -f "$HOME/.cargo/bin/rustup" ]; then
if ! confirm "Rust (rustup) is already installed. Reinstall/Upgrade?"; then
log_info "Skipping Rust installation."
return
fi
else
if ! confirm "Install Rust (rustup)?"; then
log_info "Skipping Rust installation."
return
fi
fi
install_curl
log_info "Downloading and running the official rustup installer..."
# The -s -- -y flag runs the rustup installer non-interactively, accepting defaults.
# --no-modify-path prevents the installer from modifying the shell startup files,
# as we handle this cleanly ourselves using bootstrap's configure_shell.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
}
configure_shell() {
# Add ~/.cargo/bin to PATH for the current process
export PATH="$HOME/.cargo/bin:$PATH"
IFS=' ' read -ra target_files <<< "$(get_shell_configs)"
for config_file in "${target_files[@]}"; do
log_info "Configuring Rust environment in $config_file..."
local content='. "$HOME/.cargo/env"'
inject_block "$config_file" "rust init" "$content"
# Source if modified (only for bashrc)
if [ "$config_file" = "$HOME/.bashrc" ]; then
. "$config_file" 2>/dev/null || true
fi
done
}
main() {
install_rust
configure_shell
echo
log_success "Rust (rustup) installation and configuration complete."
}
main "$@"

View File

@@ -12,6 +12,7 @@ The goal is simple: reduce the number of manual steps required after installing
| `install_bat.sh` | Installs Bat (alternative to cat) and configures alias. |
| `install_node.sh` | Installs Node.js (LTS) and NVM (Node Version Manager). |
| `install_nvim.sh` | Installs Neovim 0.11.7 and clones my Neovim configuration repository. |
| `install_rust.sh` | Installs Rust (rustup) and configures cargo environment. |
| `install_yazi.sh` | Installs Yazi terminal file manager and its dependencies. |
| `install_zoxide.sh` | Installs Zoxide directory jumper and configures shell integrations. |

View File

@@ -22,13 +22,14 @@ declare -A INSTALLERS=(
[node]="Install Node.js (LTS) and NVM"
[nvim]="Install Neovim 0.11.7 and configuration"
[pnpm]="Install pnpm package manager"
[rust]="Install Rustup and Rust compiler/toolchain"
[starship]="Install Starship shell prompt"
[yay]="Install Yay AUR helper"
[yazi]="Install Yazi terminal file manager and dependencies"
[zoxide]="Install Zoxide directory jumper"
)
# Order in which installers should be displayed
INSTALLER_KEYS=(agy bat node nvim pnpm starship yay yazi zoxide)
INSTALLER_KEYS=(agy bat node nvim pnpm rust starship yay yazi zoxide)
SCRIPT_NAMES="${1:-}"
if [ -z "$SCRIPT_NAMES" ] || [ "$SCRIPT_NAMES" = "-h" ] || [ "$SCRIPT_NAMES" = "--help" ]; then