dotfiles/.chezmoiscripts/run_once_before_02-install-rust.sh.tmpl
2026-01-29 16:27:35 -04:00

30 lines
826 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
echo "==> Rust toolchain installed successfully!"
echo " rustc: $(rustc --version)"
echo " cargo: $(cargo --version)"