diff --git a/home/.chezmoi.toml.tmpl b/home/.chezmoi.toml.tmpl index d779de5..591e27c 100644 --- a/home/.chezmoi.toml.tmpl +++ b/home/.chezmoi.toml.tmpl @@ -1,10 +1,15 @@ {{ $email := promptStringOnce . "email" "What is your main git email address " }} {{ $signinkey := promptStringOnce . "signingkey" "What is your git signing key " }} -{{ $hasLatex := promptBoolOnce . "hasLatex" "Do i install latex files " }} +{{ $hasNVim := promptBool "Do i install Neovim " false}} +{{ $hasLVim := promptBool "Do i install LunarVim " false }} +{{ $hasLatex := promptBool "Do i install latex " false }} [git] autoCommit = true autoPush = true [data] +hasNVim = {{ $hasNVim }} +hasLVim = {{ $hasLVim }} +hasLatex = {{ $hasLatex }} email = {{ $email | quote }} signinkey = {{ $signinkey | quote }} -hasLatex = {{ $hasLatex }} + diff --git a/home/.chezmoiscripts/run_once_after_10-install-packages.sh.tmpl b/home/.chezmoiscripts/run_once_after_10-install-packages.sh.tmpl index 399fefd..9714d74 100644 --- a/home/.chezmoiscripts/run_once_after_10-install-packages.sh.tmpl +++ b/home/.chezmoiscripts/run_once_after_10-install-packages.sh.tmpl @@ -3,13 +3,23 @@ # include lib . ${CHEZMOI_WORKING_TREE}/scripts/utils.sh +# args +args="--base --zsh" + +{{- if (ne .hasNVim false) }} + args="${args} --nvim" +{{- end }} + +{{- if (ne .hasLatex false) }} + args="${args} --latex" +{{- end }} {{ if (eq .chezmoi.os "linux") -}} {{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}} log "Begin Arch/Manjaro Linux packages installation" - . {{ .chezmoi.workingTree }}/scripts/archlinux.sh + . {{ .chezmoi.workingTree }}/scripts/archlinux.sh ${args} log "Finish Arch/Manjaro Linux packages installation" diff --git a/home/.chezmoiscripts/run_once_after_20-install-asdf-plugins.sh.tmpl b/home/.chezmoiscripts/run_once_after_20-install-asdf-plugins.sh.tmpl index fc17f01..90a7b61 100644 --- a/home/.chezmoiscripts/run_once_after_20-install-asdf-plugins.sh.tmpl +++ b/home/.chezmoiscripts/run_once_after_20-install-asdf-plugins.sh.tmpl @@ -1,17 +1,8 @@ #!{{ lookPath "bash" }} -# Load asdf -. "$HOME/.asdf/asdf.sh" - -# Logging function -log() { - printf "$(tput setaf 4)$(tput bold)>>>>> %s <<<<<$(tput sgr0)\n" "$1" -} - -inf() { - printf "$(tput setaf 2)╚═══ᐳ $(tput sgr 0 1)$(tput setaf 2)%s$(tput sgr0)\n" "$1" -} - +# include lib +. ${CHEZMOI_WORKING_TREE}/scripts/utils.sh +. ${HOME}/.asdf/asdf.sh # Plugins to install @@ -27,7 +18,6 @@ plugins=( ) - ### Install ASDF plugins ### log "Begin ASDF plugins installation" diff --git a/home/.chezmoiscripts/run_once_after_30-install-lvim.sh.tmpl b/home/.chezmoiscripts/run_once_after_30-install-lvim.sh.tmpl new file mode 100644 index 0000000..d8a6436 --- /dev/null +++ b/home/.chezmoiscripts/run_once_after_30-install-lvim.sh.tmpl @@ -0,0 +1,17 @@ +#!{{ lookPath "bash" }} + +# include lib +. ${CHEZMOI_WORKING_TREE}/scripts/utils.sh + +# LVim version +lvim_version="1.4" + +{{- if (and (ne .hasNVim false) (ne .hasLatex false)) }} + + log "Begin LVim installation" + + LV_BRANCH="release-${lvim_version}/neovim-0.9" bash <(curl -s "https://raw.githubusercontent.com/LunarVim/LunarVim/release-${lvim_version}/neovim-0.9/utils/installer/install.sh") + + log "Finish LVim installation" + +{{- end }} diff --git a/home/.chezmoiscripts/run_once_after_30-install-nvim.sh.tmpl b/home/.chezmoiscripts/run_once_after_30-install-nvim.sh.tmpl deleted file mode 100644 index 6544aac..0000000 --- a/home/.chezmoiscripts/run_once_after_30-install-nvim.sh.tmpl +++ /dev/null @@ -1,83 +0,0 @@ -#!{{ lookPath "bash" }} - -# Logging function -log() { - printf "$(tput setaf 4)$(tput bold)>>>>> %s <<<<<$(tput sgr0)\n" "$1" -} - -inf() { - printf "$(tput setaf 2)╚═══ᐳ $(tput sgr 0 1)$(tput setaf 2)%s$(tput sgr0)\n" "$1" -} - - - -# Packages to install -packages=( - neovim - python-pip - python-pynvim - ripgrep -) - -# LVim version -lvim_version="1.4" - - - -log "Begin LVim installation" - -{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}} - - ## Update system - inf "updating system..." - yay -Syu --noconfirm --removemake --quiet - - ## Install packages - for package in ${packages[@]}; do - if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then - inf "installing ${package}..." - yay -S --noconfirm --removemake --quiet $package - fi - done - -{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}} - - export DEBIAN_FRONTEND=noninteractive - - ## Update system - inf "updating system..." - {{- if ne .chezmoi.username "root" }} - sudo -E apt update -qq - sudo -E apt upgrade --yes -qq - {{- else }} - apt update -qq - apt upgrade --yes -qq - {{- end}} - - ## Install packages - ## packages[1]=golang - packages=(${packages[@]/python/python3}) - packages=(${packages[@]/neovim/}) - packages+=(python3-venv) - - for package in ${packages[@]}; do - inf "installing ${package}..." - - {{- if ne .chezmoi.username "root" }} - sudo -E apt-get install --yes --no-install-recommends --ignore-missing --fix-broken -qq $package - {{- else }} - apt-get install --yes --no-install-recommends --ignore-missing --fix-broken -qq $package - {{- end }} - done - - inf "installing neovim..." - mist install neovim - -{{- end }} - -inf "installing lvim..." -LV_BRANCH="release-${lvim_version}/neovim-0.9" bash <(curl -s "https://raw.githubusercontent.com/LunarVim/LunarVim/release-${lvim_version}/neovim-0.9/utils/installer/install.sh") - -log "Finish LVim installation" - - diff --git a/home/.chezmoiscripts/run_once_after_40-install-shell.sh.tmpl b/home/.chezmoiscripts/run_once_after_40-install-shell.sh.tmpl index 3758efa..21bfde8 100644 --- a/home/.chezmoiscripts/run_once_after_40-install-shell.sh.tmpl +++ b/home/.chezmoiscripts/run_once_after_40-install-shell.sh.tmpl @@ -1,110 +1,37 @@ #!{{ lookPath "bash" }} -# Load asdf -# as we need cargo and it is installed from -. "$HOME/.asdf/asdf.sh" - - -# Logging function -log() { - printf "$(tput setaf 4)$(tput bold)>>>>> %s <<<<<$(tput sgr0)\n" "$1" -} - -inf() { - printf "$(tput setaf 2)╚═══ᐳ $(tput sgr 0 1)$(tput setaf 2)%s$(tput sgr0)\n" "$1" -} - - +# include lib +. ${CHEZMOI_WORKING_TREE}/scripts/utils.sh +. ${HOME}/.asdf/asdf.sh # Environment variables ZIMDIR=${HOME}/.zim -# Packages to install -packages=( - zsh -) - - -### Install Zsh ### -log "Begin Zsh installation" - -{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}} - - ## Update system - inf "updating system..." - yay -Syu --noconfirm --removemake --quiet - - ## install packages - for package in ${packages[@]}; do - if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then - inf "installing ${package}..." - yay -S --noconfirm --removemake --quiet $package - fi - done - -{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}} - export DEBIAN_FRONTEND=noninteractive - - ## Update system - inf "updating system..." - {{- if ne .chezmoi.username "root" }} - sudo -E apt update -qq - sudo -E apt upgrade --yes -qq - {{- else }} - apt update -qq - apt upgrade --yes -qq - {{- end}} - - ## packages=(${packages[@]//starship/}) - - ## install packages - for package in ${packages[@]}; do - inf "installing ${package}..." - - {{- if ne .chezmoi.username "root" }} - sudo -E apt-get install --yes --no-install-recommends --ignore-missing --fix-broken -qq $package - {{- else }} - apt-get install --yes --no-install-recommends --ignore-missing --fix-broken -qq $package - {{- end }} - done - - ## inf "installing starship..." - ## mist install starship-bin - -{{- end }} - -log "Finish Zsh installation" +### Update shell install ### +log "Begin Zsh customization" ## Update cargo -log "Installing cargo-update" +inf "installing cargo-update..." cargo install cargo-update -log "Finish cargo-update installation" - - ## Install Atuin -log "Installing atuin" +inf "installing atuin..." cargo install atuin -log "Finish atuin installation" - - ## Reshim -log "Asdf reshim..." +inf "asdf reshim..." asdf reshim -log "Reshim ok." - - ### Config Zsh ### -log "Installing Zim Framework" +inf "installing zim framework" $(which zsh) -c "source ${ZIMDIR}/zimfw.zsh init -q" -log "Finish zsh installation" + +log "Finish Zsh customization" diff --git a/home/.chezmoiscripts/run_once_after_50-finalize-latex.sh.tmpl b/home/.chezmoiscripts/run_once_after_50-finalize-latex.sh.tmpl index 7ee42e4..042a166 100644 --- a/home/.chezmoiscripts/run_once_after_50-finalize-latex.sh.tmpl +++ b/home/.chezmoiscripts/run_once_after_50-finalize-latex.sh.tmpl @@ -1,26 +1,17 @@ #!{{ lookPath "bash" }} -# Logging function -log() { - printf "$(tput setaf 4)$(tput bold)>>>>> %s <<<<<$(tput sgr0)\n" "$1" -} - -inf() { - printf "$(tput setaf 2)╚═══ᐳ $(tput sgr 0 1)$(tput setaf 2)%s$(tput sgr0)\n" "$1" -} - - +# include lib +. ${CHEZMOI_WORKING_TREE}/scripts/utils.sh # Environment variables TEXMFDIR=${HOME}/texmf/tex/latex - {{- if (ne .hasLatex false) }} -log "Begin LaTeX repo initialization" + log "Begin LaTeX repo initialization" -texhash "${TEXMFDIR}" + texhash "${TEXMFDIR}" -log "Finish LaTeX repo initialization" + log "Finish LaTeX repo initialization" {{ end -}} diff --git a/scripts/archlinux.sh b/scripts/archlinux.sh index 0ddcb18..0620adf 100644 --- a/scripts/archlinux.sh +++ b/scripts/archlinux.sh @@ -4,38 +4,112 @@ . ${CHEZMOI_WORKING_TREE}/scripts/utils.sh -# Packages to install -packages=( - bubblewrap - curl - fzf - pass - libyaml - ranger - tmux - trash-cli - ueberzug - unzip - wget - zip - zoxide -) +# usage +usage() { + printf "\nUsage:\n" + echo " --base Install base pacakges" + echo " --nvim Install deps for NeoVim" + echo " --zsh Install deps for zsh" + echo " --latex Install deps for latex" +} +# packages to install +install_base() { + packages=( + bubblewrap + curl + fzf + pass + libyaml + ranger + tmux + trash-cli + ueberzug + unzip + wget + zip + zoxide + ) +} -## Update system -inf "updating system..." -sudo pacman -Syu --noconfirm --quiet +install_nvim() { + packages+=( + neovim + python-pip + python-pynvim + ripgrep + ) +} -## Install yay -if [ ! $(command -v yay) ]; then - install_binary "yay" +install_zsh() { + packages+=( + zsh + ) +} + +install_latex() { + packages+=( + texlive-basic + texlive-latex + texlive-latexrecommended + texlive-latexextra + texlive-fontsrecommended + texlive-fontsextre + texlive-luatex + texlive-mathscience + texlive-lang + ) +} + +# cli options +BASE=false +NVIM=false +ZSH=false +LATEX=false + +if [ "$#" -eq 0 ]; then + usage + exit 1 fi -## Install packages -for package in ${packages[@]}; do - if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then - install_binary $package "yay" - else - inf "${package} already installed." - fi +while [ "$#" -gt 0 ]; do + case "$1" in + --base) BASE=true ;; + --nvim) NVIM=true ;; + --zsh) ZSH=true ;; + --latex) LATEX=true ;; + *) + usage + exit 1 + ;; + esac + shift done + +main() { + "$BASE" && install_base + "$NVIM" && install_nvim + "$ZSH" && install_zsh + "$LATEX" && install_latex + + ## Update system + update_system + + ## Install yay + if [ ! $(command -v yay) ]; then + install_binary "yay" + fi + + ## Install packages + for package in ${packages[@]}; do + if [ "$(yay -Qq $package 2> /dev/null)" != $package ]; then + install_binary $package "yay" + else + inf "${package} already installed." + fi + done + + exit 0 +} + +main "$@" \ No newline at end of file diff --git a/scripts/utils.sh b/scripts/utils.sh index 13c6404..f1abf35 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -13,9 +13,24 @@ err() { printf "$(tput setaf 9)$(tput bold)>>>>> %s ! <<<<<$(tput sgr0)\n" "$1" } +# Function to determine the package manager if not specified +determine_package_manager() { + if [ command -v apt-get &>/dev/null ]; then + echo "apt" + elif [ command -v pamac &>/dev/null ]; then + echo "pamac" + elif [ command -v yay &>/dev/null ]; then + echo "yay" + elif [ command -v pacman &>/dev/null ]; then + echo "pacman" + else + err "No supported package manager found." + exit 1 + fi +} + +# Simple abstraction to install a binary using a supported package manager install_binary() { - ## - # Simple abstraction to install a binary using a supported package manager # Example usage: # install_binary "fzf" # install_binary "fzf" "dnf" @@ -23,61 +38,89 @@ install_binary() { local package_name="${1}" local package_manager="${2}" - # Function to determine the package manager if not specified - determine_package_manager() { - if [ command -v apt-get &>/dev/null ]; then - echo "apt-get" - elif [ command -v pamac &>/dev/null ]; then - echo "pamac" - elif [ command -v yay &>/dev/null ]; then - echo "yay" - elif [ command -v pacman &>/dev/null ]; then - echo "pacman" - else - err "No supported package manager found." + # If the package manager is not specified, determine it + if [[ -z "${package_manager}" ]]; then + package_manager=$(determine_package_manager) + fi + + # Install the package using the determined or specified package manager + inf "installing ${package_name} using ${package_manager}..." + + case "${package_manager}" in + apt) + sudo apt-get install --yes --no-install-recommends --ignore-missing --fix-broken -qq "${package_name}" || { + err "Installation failed." + exit 1 + } + ;; + pacman) + sudo pacman -S --needed --noconfirm --quiet "${package_name}" || { + err "Installation failed." + exit 1 + } + ;; + pamac) + sudo pamac --no-confirm "${package_name}" || { + err "Installation failed." + exit 1 + } + ;; + yay) + yay -S --noconfirm --removemake --quiet "${package_name}" || { + err "Installation failed." + exit 1 + } + ;; + *) + err "Unsupported package manager: ${package_manager}" exit 1 - fi - } + ;; + esac + + inf "installation of ${package_name} completed successfully." +} + +update_system() { + local package_manager="${1}" # If the package manager is not specified, determine it if [[ -z "${package_manager}" ]]; then package_manager=$(determine_package_manager) fi - # Install the package using the determined or specified package manager - inf "installing ${package_name} using ${package_manager}..." + # Install the package using the determined or specified package manager + inf "updating system using ${package_manager}..." case "${package_manager}" in - apt-get) - sudo apt-get install --yes --no-install-recommends --ignore-missing --fix-broken -qq "${package_name}" || { - err "Installation failed." - exit 1 - } + apt) + sudo -E apt update -qq && sudo -E apt upgrade --yes -qq || { + err "Installation failed." + exit 1 + } ;; - pacman) - sudo pacman -S --needed --noconfirm --quiet "${package_name}" || { - err "Installation failed." - exit 1 - } + pacman) + sudo pacman -Syu --noconfirm --removemake --quiet || { + err "Installation failed." + exit 1 + } ;; - pamac) - sudo pamac --no-confirm "${package_name}" || { - err "Installation failed." - exit 1 - } + pamac) + sudo pamac update --aur --no-confirm && sudo pamac upgrade --aur --no-confirm || { + err "Installation failed." + exit 1 + } ;; - yay) - yay -S --noconfirm --removemake --quiet "${package_name}" || { - err "Installation failed." - exit 1 - } + yay) + yay -Syu --noconfirm --removemake --quiet || { + err "Installation failed." + exit 1 + } ;; - *) - err "Unsupported package manager: ${package_manager}" - exit 1 + *) + err "Unsupported package manager: ${package_manager}" + exit 1 ;; esac - inf "installation of ${package_name} completed successfully." + + inf "system update completed successfully." } - -