dotfiles/.chezmoiscripts/run_once_before_02-install-rust.sh.tmpl

34 lines
974 B
Bash

#!/bin/bash
# Install Rust toolchain via rustup
# This script runs once before other chezmoi operations
set -e
echo "==> Installing Rust toolchain..."
# Install rustup if not present
if ! command -v rustup &> /dev/null; then
echo "==> Installing rustup..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
# Source cargo environment for this script
source "$HOME/.cargo/env"
else
echo "==> rustup already installed, updating..."
rustup update
fi
# Ensure stable toolchain is installed
rustup default stable
# Install common Rust components
echo "==> Installing Rust components..."
rustup component add rustfmt clippy rust-analyzer
# Install useful cargo tools
echo "==> Installing cargo tools..."
cargo install --locked cargo-watch cargo-edit cargo-outdated 2>/dev/null || true
echo "==> Rust toolchain installed successfully!"
echo " rustc: $(rustc --version)"
echo " cargo: $(cargo --version)"