From d93bc7aae38a465132267f5559374fc51510c158 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen <11024+ivuorinen@users.noreply.github.com> Date: Sat, 6 Jul 2024 20:19:15 +0300 Subject: [PATCH] feat(asdf): asdf and configuration (#19) * chore(shell): configuration tweaks * feat(asdf): add asdf, settings & most of the deps --- base/bashrc | 35 ++++------------- base/zshrc | 16 ++------ config/asdf/asdfrc | 8 ++++ config/asdf/npm-packages | 7 ++++ config/asdf/plugin-versions | 27 +++++++++++++ config/asdf/tool-versions | 16 ++++++++ config/exports-apps | 13 +++++++ config/shared | 24 ++++++++++++ local/bin/dfm | 20 ++++++---- scripts/install-asdf.sh | 78 +++++++++++++++++++++++++++++++++++++ 10 files changed, 197 insertions(+), 47 deletions(-) create mode 100644 config/asdf/asdfrc create mode 100644 config/asdf/npm-packages create mode 100644 config/asdf/plugin-versions create mode 100644 config/asdf/tool-versions create mode 100644 config/shared create mode 100755 scripts/install-asdf.sh diff --git a/base/bashrc b/base/bashrc index 764fde8..6c9c734 100644 --- a/base/bashrc +++ b/base/bashrc @@ -1,26 +1,8 @@ # this is my bashrc config. there are many like it, but this one is mine. # shellcheck shell=bash -# Defaults -export DOTFILES="$HOME/.dotfiles" +source "$HOME/.dotfiles/config/shared" -# Explicitly set XDG folders -# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html -export XDG_CONFIG_HOME="$HOME/.config" -export XDG_DATA_HOME="$HOME/.local/share" -export XDG_STATE_HOME="$HOME/.local/state" - -# custom variables -export XDG_BIN_HOME="$HOME/.local/bin" -export XDG_CACHE_HOME="$HOME/.cache" -export XDG_RUNTIME_DIR="$HOME/.local/run" - -# Paths -export PATH="$XDG_BIN_HOME:$DOTFILES/local/bin:$HOME/.local/go/bin:$XDG_DATA_HOME/cargo/bin:$PATH" - -source "$DOTFILES/config/exports" -source "$DOTFILES/config/functions" -source "$DOTFILES/config/alias" x-load-configs # shellcheck source=../config/fzf/fzf.bash @@ -30,14 +12,13 @@ x-load-configs # Import ssh keys in keychain ssh-add -A 2>/dev/null +x-have oh-my-posh && { + eval "$(oh-my-posh init bash --config "$DOTFILES/config/omp/own.toml")" +} + +. "$HOME/.local/share/asdf/asdf.sh" +. "$HOME/.local/share/asdf/completions/asdf.bash" + x-have antidot && { eval "$(antidot init)" } - -x-have rbenv && { - eval "$(rbenv init - bash)" -} - -x-have oh-my-posh && { - eval "$(oh-my-posh init bash --config $DOTFILES/config/omp/own.toml)" -} diff --git a/base/zshrc b/base/zshrc index bf22029..e27c1db 100755 --- a/base/zshrc +++ b/base/zshrc @@ -1,25 +1,14 @@ # this is my zsh config. there are many like it, but this one is mine. # shellcheck shell=bash -export DOTFILES="$HOME/.dotfiles" - -# Explicitly set XDG folders -# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html -export XDG_CONFIG_HOME="$HOME/.config" -export XDG_DATA_HOME="$HOME/.local/share" -export XDG_STATE_HOME="$HOME/.local/state" - -# custom variables -export XDG_BIN_HOME="$HOME/.local/bin" -export XDG_CACHE_HOME="$HOME/.cache" -export XDG_RUNTIME_DIR="$HOME/.local/run" +source "$HOME/.dotfiles/config/shared" export PATH="$XDG_BIN_HOME:$DOTFILES/local/bin:$HOME/.local/go/bin:$XDG_DATA_HOME/bob/nvim-bin:$XDG_DATA_HOME/cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" x-load-configs x-have oh-my-posh && { - eval "$(oh-my-posh init zsh --config $DOTFILES/config/omp/own.toml)" + eval "$(oh-my-posh init zsh --config "$DOTFILES/config/omp/own.toml")" } export COMPLETION_WAITING_DOTS=true @@ -57,6 +46,7 @@ export ZSHZ_DATA="$XDG_STATE_HOME/z" antigen bundle z # these should be always available +antigen bundle asdf antigen bundle tmux antigen bundle colored-man-pages antigen bundle ssh-agent diff --git a/config/asdf/asdfrc b/config/asdf/asdfrc new file mode 100644 index 0000000..c8e02f8 --- /dev/null +++ b/config/asdf/asdfrc @@ -0,0 +1,8 @@ +# See the docs for explanations: https://asdf-vm.com/manage/configuration.html + +legacy_version_file = yes +use_release_candidates = no +always_keep_download = no +plugin_repository_last_check_duration = 60 +disable_plugin_short_name_repository = no +concurrency = auto diff --git a/config/asdf/npm-packages b/config/asdf/npm-packages new file mode 100644 index 0000000..4ee9bfd --- /dev/null +++ b/config/asdf/npm-packages @@ -0,0 +1,7 @@ +blade-formatter +corepack +editorconfig-checker +github-release-notes +neovim +npm +stylelint-lsp diff --git a/config/asdf/plugin-versions b/config/asdf/plugin-versions new file mode 100644 index 0000000..e56f9a9 --- /dev/null +++ b/config/asdf/plugin-versions @@ -0,0 +1,27 @@ +1password-cli https://github.com/NeoHsu/asdf-1password-cli.git f5d5aab +age https://github.com/threkk/asdf-age.git 4df80a0 +asdf-plugin-manager https://github.com/asdf-community/asdf-plugin-manager.git 50d2735 +bottom https://github.com/carbonteq/asdf-btm.git fd8a55a +dotenv-linter https://github.com/wesleimp/asdf-dotenv-linter.git 1369f53 +editorconfig-checker https://github.com/gabitchov/asdf-editorconfig-checker.git 585c1d5 +eza https://github.com/lwiechec/asdf-eza.git 08c1b65 +fd https://gitlab.com/wt0f/asdf-fd.git 17d56e0 +github-cli https://github.com/bartlomiejdanek/asdf-github-cli.git e0605b7 +hadolint https://github.com/devlincashman/asdf-hadolint.git 335e230 +kubectl https://github.com/asdf-community/asdf-kubectl.git cbe6df4 +lazygit https://github.com/nklmilojevic/asdf-lazygit.git 78e04f1 +neovim https://github.com/richin13/asdf-neovim d6118ad +nodejs https://github.com/asdf-vm/asdf-nodejs.git c5b7c40 +pipx https://github.com/yozachar/asdf-pipx.git 31db618 +pre-commit https://github.com/jonathanmorley/asdf-pre-commit.git 26bfc42 +ripgrep https://gitlab.com/wt0f/asdf-ripgrep.git e836665 +semgrep https://github.com/brentjanderson/asdf-semgrep.git 13ff78b +shellcheck https://github.com/luizm/asdf-shellcheck.git 780d78d +shfmt https://github.com/luizm/asdf-shfmt.git a42c5ff +terraform-ls https://github.com/asdf-community/asdf-hashicorp.git f1602b6 +terraform-lsp https://github.com/bartlomiejdanek/asdf-terraform-lsp.git bba7106 +terragrunt https://github.com/ohmer/asdf-terragrunt 4a6651a +tf-summarize https://github.com/adamcrews/asdf-tf-summarize.git 880ad26 +vault https://github.com/asdf-community/asdf-hashicorp.git f1602b6 +yamllint https://github.com/ericcornelissen/asdf-yamllint.git d5c3161 +yq https://github.com/sudermanjr/asdf-yq.git 772992f diff --git a/config/asdf/tool-versions b/config/asdf/tool-versions new file mode 100644 index 0000000..2985c65 --- /dev/null +++ b/config/asdf/tool-versions @@ -0,0 +1,16 @@ +1password-cli 2.29.0 +age 1.2.0 +bottom 0.9.6 +eza 0.18.19 +fd 10.1.0 +hadolint 2.12.0 +kubectl 1.30.2 +lazygit 0.42.0 +nodejs 22.3.0 +pipx 1.6.0 +tf-summarize 0.3.10 +vault 1.17.0+ent +yamllint 1.35.1 +yq 4.44.2 +neovim system +asdf-plugin-manager 1.3.1 diff --git a/config/exports-apps b/config/exports-apps index 26b984a..993bdae 100755 --- a/config/exports-apps +++ b/config/exports-apps @@ -21,6 +21,19 @@ x-dc "$ANSIBLE_GALAXY_CACHE_DIR" export ANDROID_HOME="$XDG_DATA_HOME/android" +# asdf +# https://github.com/asdf-vm/asdf +export ASDF_DIR="${XDG_DATA_HOME}/asdf" +export ASDF_CONFIG_FILE="${XDG_CONFIG_HOME}/asdf/asdfrc" +export ASDF_DATA_DIR="${ASDF_DIR}" +# This seems wrong, but `asdf info` and `versions.bash` differ on path resolution. +export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=".config/asdf/tool-versions" +export ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME="${XDG_CONFIG_HOME}/asdf/plugin-versions" +export ASDF_LOG_FILE="${XDG_CACHE_HOME}/asdf/asdf.log" +export ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY="latest_available" +export ASDF_NPM_DEFAULT_PACKAGES_FILE="${XDG_CONFIG_HOME}/asdf/npm-packages" +export PATH="${ASDF_DIR}/bin:${PATH}" + # bob manages nvim versions export PATH="$XDG_DATA_HOME/bob/nvim-bin:$PATH" diff --git a/config/shared b/config/shared new file mode 100644 index 0000000..702d749 --- /dev/null +++ b/config/shared @@ -0,0 +1,24 @@ +# shellcheck shell=bash + +# Defaults +export DOTFILES="$HOME/.dotfiles" + +# Explicitly set XDG folders +# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_STATE_HOME="$HOME/.local/state" + +# custom variables +export XDG_BIN_HOME="$HOME/.local/bin" +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_RUNTIME_DIR="$HOME/.local/run" + +# Paths +export PATH="$XDG_BIN_HOME:$DOTFILES/local/bin:$HOME/.local/go/bin:$XDG_DATA_HOME/bob/nvim-bin:$XDG_DATA_HOME/cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" + +# Split config files +source "$DOTFILES/config/exports" +source "$DOTFILES/config/functions" +source "$DOTFILES/config/alias" + diff --git a/local/bin/dfm b/local/bin/dfm index 86229af..3365b1a 100755 --- a/local/bin/dfm +++ b/local/bin/dfm @@ -62,19 +62,20 @@ function section_install $0 install antigen $0 brew install $0 install ohmyposh - $0 install ohmybash - $0 install pip + $0 install asdf + # $0 install ohmybash + # $0 install pip $0 install cargo $0 install composer - $0 install dotenv + # $0 install dotenv $0 install fzf - $0 install gh + # $0 install gh $0 install go $0 install cheat-databases $0 install imagick - $0 install neofetch - $0 install nvm - $0 install npm + # $0 install neofetch + # $0 install nvm + # $0 install npm $0 install ntfy $0 install z msgr msg "Reloading configurations again..." @@ -86,6 +87,11 @@ function section_install curl -sSfL git.io/antigen -o "$DOTFILES/local/bin/antigen.zsh" \ && msg_yay "New antigen installed!" ;; + asdf) + msg "Installing asdf..." + bash "$DOTFILES/scripts/install-asdf.sh" \ + && msg_yay "asdf installed!" + ;; cargo) msg "Installing cargo packages..." bash "$DOTFILES/scripts/install-cargo-packages.sh" \ diff --git a/scripts/install-asdf.sh b/scripts/install-asdf.sh new file mode 100755 index 0000000..349d961 --- /dev/null +++ b/scripts/install-asdf.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +# +# Install asdf + +source "${XDG_CONFIG_HOME}/exports" +source "${XDG_CONFIG_HOME}/alias" +source "${XDG_CONFIG_HOME}/functions" +source "${DOTFILES}/scripts/shared.sh" + +# Installation variables +ASDF_GIT="https://github.com/asdf-vm/asdf.git" +ASDF_PATH="${XDG_DATA_HOME}/asdf" + +if [ ! -d "$ASDF_PATH" ]; then + git clone --depth 1 "$ASDF_GIT" "$ASDF_PATH" \ + --branch v0.14.0 + + msg_done "asdf ($ASDF_PATH/) installed" +else + msg_done "asdf ($ASDF_PATH/) already installed" +fi + +export PATH="${ASDF_PATH}/bin:$PATH" + +msg "Sourcing asdf in your shell" +. "$ASDF_PATH/asdf.sh" + +# Update asdf, and plugins +asdf update + +asdf plugin add asdf-plugin-manager https://github.com/asdf-community/asdf-plugin-manager.git +asdf install asdf-plugin-manager latest +asdf global asdf-plugin-manager "$(asdf latest asdf-plugin-manager)" +asdf-plugin-manager version +asdf-plugin-manager export > "${ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME}" +asdf-plugin-manager add-all + +asdf install + +# ASDF_INSTALLABLES=( +# "nodejs:github.com/asdf-vm/asdf-nodejs.git" +# "1password-cli:github.com/NeoHsu/asdf-1password-cli.git" +# "age:github.com/threkk/asdf-age.git" +# "bottom:github.com/carbonteq/asdf-btm.git" +# "dotenv-linter:github.com/wesleimp/asdf-dotenv-linter.git" +# "editorconfig-checker:github.com/gabitchov/asdf-editorconfig-checker.git" +# "eza:github.com/lwiechec/asdf-eza.git" +# "fd:gitlab.com/wt0f/asdf-fd.git" +# "github-cli:github.com/bartlomiejdanek/asdf-github-cli.git" +# "hadolint:github.com/devlincashman/asdf-hadolint.git" +# "kubectl:github.com/asdf-community/asdf-kubectl.git" +# "lazygit:github.com/nklmilojevic/asdf-lazygit.git" +# "pipx:github.com/yozachar/asdf-pipx.git" +# "pre-commit:github.com/jonathanmorley/asdf-pre-commit.git" +# "ripgrep:gitlab.com/wt0f/asdf-ripgrep.git" +# "semgrep:github.com/brentjanderson/asdf-semgrep.git" +# "terraform-ls:github.com/asdf-community/asdf-hashicorp.git" +# "vault:github.com/asdf-community/asdf-hashicorp.git" +# "shellcheck:github.com/luizm/asdf-shellcheck.git" +# "shfmt:github.com/luizm/asdf-shfmt.git" +# "terraform-lsp:github.com/bartlomiejdanek/asdf-terraform-lsp.git" +# "terragrunt:github.com/ohmer/asdf-terragrunt.git" +# "tf-summarize:github.com/adamcrews/asdf-tf-summarize.git" +# "yamllint:github.com/ericcornelissen/asdf-yamllint.git" +# "yq:github.com/sudermanjr/asdf-yq.git" +# ) +# +# msg "Installing asdf plugins, if not already installed" +# for item in "${ASDF_INSTALLABLES[@]}"; do +# CMD=$(echo "${item}" | awk -F ":" '{print $1}') +# URL=$(echo "${item}" | awk -F ":" '{print $2}') +# asdf plugin add "${CMD}" "https://${URL}" +# asdf install "${CMD}" latest +# asdf global "${CMD}" "$(asdf latest "${CMD}")" +# done + +msg "Reshim asdf" +asdf reshim