diff --git a/config/asdf/cargo-packages b/config/asdf/cargo-packages deleted file mode 100644 index a40c009..0000000 --- a/config/asdf/cargo-packages +++ /dev/null @@ -1,27 +0,0 @@ -// A cargo subcommand for checking and applying -// updates to installed executables -cargo-update -// Cargo cache management utility -cargo-cache -// An incremental parsing system for programming tools -tree-sitter-cli -// a subprocess caching utility -bkt -// a structural diff that understands syntax -difftastic -// A simple, fast and user-friendly alternative to 'find' -fd-find -// recursively searches directories for a -// regex pattern while respecting your gitignore -ripgrep -// A version manager for neovim -bob-nvim -// bottom, btm - A cross-platform graphical process/system monitor with -// a customizable interface and a multitude of features. -bottom -// A modern alternative to ls -eza -// Tmux Sessionizer: A tool for opening git repositories as tmux sessions -tmux-sessionizer -// zoxide, a smarter cd command -zoxide diff --git a/scripts/install-cargo-packages.md b/scripts/install-cargo-packages.md index 1d30426..96b1cec 100644 --- a/scripts/install-cargo-packages.md +++ b/scripts/install-cargo-packages.md @@ -1,6 +1,6 @@ # install-cargo-packages -Install Rust packages listed in `config/asdf/cargo-packages`. +Install Rust packages defined in the script. ## Usage @@ -8,5 +8,14 @@ Install Rust packages listed in `config/asdf/cargo-packages`. scripts/install-cargo-packages.sh ``` -The script installs each package with `cargo install` and runs -`cargo-install-update` when available to update existing packages. +## What it does + +1. If `cargo-install-update` is available, updates all existing packages first + and tracks which packages are already installed. +2. Installs each package from the inline list using `cargo install`, + skipping any already handled by the update step. + Builds run in parallel using available CPU cores (minus two). +3. Runs package-specific post-install steps. +4. Cleans the cargo cache with `cargo cache --autoclean`. + +To add or remove packages, edit the `packages` array in `scripts/install-cargo-packages.sh`. diff --git a/scripts/install-cargo-packages.sh b/scripts/install-cargo-packages.sh index 0d3caf8..5e482ce 100755 --- a/scripts/install-cargo-packages.sh +++ b/scripts/install-cargo-packages.sh @@ -3,27 +3,37 @@ msgr run "Starting to install rust/cargo packages" +# Track packages already managed by cargo install-update +declare -A installed_packages + # If we have cargo install-update, use it first if command -v cargo-install-update &> /dev/null; then msgr run "Updating cargo packages with cargo install-update" - cargo install-update -a + # Show output in real-time (via stderr) while capturing it for parsing + update_output=$(cargo install-update -a 2>&1 | tee /dev/stderr) msgr run_done "Done with cargo install-update" + + # Parse installed package names from the update output + while IFS= read -r pkg_name; do + [[ -n "$pkg_name" ]] && installed_packages["$pkg_name"]=1 + done < <(echo "$update_output" | awk '/v[0-9]+\.[0-9]+/ { print $1 }') fi -[[ -z "$ASDF_CRATE_DEFAULT_PACKAGES_FILE" ]] \ - && ASDF_CRATE_DEFAULT_PACKAGES_FILE="$DOTFILES/config/asdf/cargo-packages" - -# Packages are defined in $DOTFILES/config/asdf/cargo-packages, one per line -# Skip comments and empty lines -packages=() -while IFS= read -r line; do - # Skip comments - if [[ ${line:0:1} == "#" ]]; then continue; fi - if [[ ${line:0:1} == "/" ]]; then continue; fi - # Skip empty lines - if [[ -z "$line" ]]; then continue; fi - packages+=("$line") -done < "$ASDF_CRATE_DEFAULT_PACKAGES_FILE" +# Cargo packages to install +packages=( + cargo-update # A cargo subcommand for checking and applying updates to installed executables + cargo-cache # Cargo cache management utility + tree-sitter-cli # An incremental parsing system for programming tools + bkt # A subprocess caching utility + difftastic # A structural diff that understands syntax + fd-find # A simple, fast and user-friendly alternative to 'find' + ripgrep # Recursively searches directories for a regex pattern while respecting your gitignore + bob-nvim # A version manager for neovim + bottom # A cross-platform graphical process/system monitor + eza # A modern alternative to ls + tmux-sessionizer # A tool for opening git repositories as tmux sessions + zoxide # A smarter cd command +) # Number of jobs to run in parallel, this helps to keep the system responsive BUILD_JOBS=$(nproc --ignore=2 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 1) @@ -32,10 +42,11 @@ BUILD_JOBS=$(nproc --ignore=2 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || install_packages() { for pkg in "${packages[@]}"; do - # Trim spaces - pkg=${pkg// /} - # Skip comments - if [[ ${pkg:0:1} == "#" ]]; then continue; fi + # Skip packages already handled by cargo install-update + if [[ -n "${installed_packages[$pkg]+x}" ]]; then + msgr ok "Skipping $pkg (already installed)" + continue + fi msgr run "Installing cargo package $pkg" cargo install --jobs "$BUILD_JOBS" "$pkg"