feat!: refactor base, config, dfm and scripts

This commit is contained in:
2024-07-23 03:43:12 +03:00
parent adecceda7a
commit 1f2ca90ca5
36 changed files with 1543 additions and 897 deletions

View File

@@ -2,18 +2,18 @@
# Install cargo/rust packages.
#
# shellcheck source=shared.sh
eval "$HOME/.dotfiles/scripts/shared.sh"
eval "$HOME/.dotfiles/config/shared.sh"
msg "Starting to install rust/cargo packages"
source "$CARGO_HOME/env"
# If we have cargo install-update, use it first
x-have cargo-install-update && {
if command -v cargo-install-update &> /dev/null; then
msg_run "Updating cargo packages with cargo install-update"
cargo install-update -a
msg_done "Done with cargo install-update"
}
fi
packages=(
# A cargo subcommand for checking and applying
@@ -42,28 +42,41 @@ packages=(
# Number of jobs to run in parallel, this helps to keep the system responsive
BUILD_JOBS=$(nproc --ignore=2)
for pkg in "${packages[@]}"; do
# Trim spaces
pkg=${pkg// /}
# Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
# Function to install cargo packages
install_packages()
{
for pkg in "${packages[@]}"; do
# Trim spaces
pkg=${pkg// /}
# Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
msg_run "Installing cargo package $pkg"
cargo install --jobs $BUILD_JOBS "$pkg"
echo ""
done
msg_done "Installed cargo packages!"
msg_run "Now doing the next steps for cargo packages"
# use bob to install latest stable nvim
x-have bob && {
bob use stable && x-path-append "$XDG_DATA_HOME/bob/nvim-bin"
msg_run "Installing cargo package $pkg"
cargo install --jobs $BUILD_JOBS "$pkg"
echo ""
done
}
msg_run "Removing cargo cache"
cargo cache --autoclean
msg_done "Done removing cargo cache"
# Function to perform additional steps for installed cargo packages
post_install_steps()
{
msg_run "Now doing the next steps for cargo packages"
# use bob to install latest stable nvim
if command -v bob &> /dev/null; then
bob use stable && x-path-append "$XDG_DATA_HOME/bob/nvim-bin"
fi
msg_run "Removing cargo cache"
cargo cache --autoclean
msg_done "Done removing cargo cache"
}
main()
{
install_packages
msg_done "Installed cargo packages!"
post_install_steps
}
main "$@"