refactor(scripts): inline cargo packages into install script

Move package list from config/asdf/cargo-packages into
install-cargo-packages.sh as a bash array and remove the
external file. Update documentation accordingly.
This commit is contained in:
2026-02-04 01:15:24 +02:00
parent d46631b017
commit e19120c45a
3 changed files with 42 additions and 49 deletions

View File

@@ -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

View File

@@ -1,6 +1,6 @@
# install-cargo-packages # install-cargo-packages
Install Rust packages listed in `config/asdf/cargo-packages`. Install Rust packages defined in the script.
## Usage ## Usage
@@ -8,5 +8,14 @@ Install Rust packages listed in `config/asdf/cargo-packages`.
scripts/install-cargo-packages.sh scripts/install-cargo-packages.sh
``` ```
The script installs each package with `cargo install` and runs ## What it does
`cargo-install-update` when available to update existing packages.
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`.

View File

@@ -3,27 +3,37 @@
msgr run "Starting to install rust/cargo packages" 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 we have cargo install-update, use it first
if command -v cargo-install-update &> /dev/null; then if command -v cargo-install-update &> /dev/null; then
msgr run "Updating cargo packages with cargo install-update" 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" 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 fi
[[ -z "$ASDF_CRATE_DEFAULT_PACKAGES_FILE" ]] \ # Cargo packages to install
&& ASDF_CRATE_DEFAULT_PACKAGES_FILE="$DOTFILES/config/asdf/cargo-packages" packages=(
cargo-update # A cargo subcommand for checking and applying updates to installed executables
# Packages are defined in $DOTFILES/config/asdf/cargo-packages, one per line cargo-cache # Cargo cache management utility
# Skip comments and empty lines tree-sitter-cli # An incremental parsing system for programming tools
packages=() bkt # A subprocess caching utility
while IFS= read -r line; do difftastic # A structural diff that understands syntax
# Skip comments fd-find # A simple, fast and user-friendly alternative to 'find'
if [[ ${line:0:1} == "#" ]]; then continue; fi ripgrep # Recursively searches directories for a regex pattern while respecting your gitignore
if [[ ${line:0:1} == "/" ]]; then continue; fi bob-nvim # A version manager for neovim
# Skip empty lines bottom # A cross-platform graphical process/system monitor
if [[ -z "$line" ]]; then continue; fi eza # A modern alternative to ls
packages+=("$line") tmux-sessionizer # A tool for opening git repositories as tmux sessions
done < "$ASDF_CRATE_DEFAULT_PACKAGES_FILE" zoxide # A smarter cd command
)
# Number of jobs to run in parallel, this helps to keep the system responsive # 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) 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() install_packages()
{ {
for pkg in "${packages[@]}"; do for pkg in "${packages[@]}"; do
# Trim spaces # Skip packages already handled by cargo install-update
pkg=${pkg// /} if [[ -n "${installed_packages[$pkg]+x}" ]]; then
# Skip comments msgr ok "Skipping $pkg (already installed)"
if [[ ${pkg:0:1} == "#" ]]; then continue; fi continue
fi
msgr run "Installing cargo package $pkg" msgr run "Installing cargo package $pkg"
cargo install --jobs "$BUILD_JOBS" "$pkg" cargo install --jobs "$BUILD_JOBS" "$pkg"