From 40d3dc2b73eb20ec08e01bee19a5452afd19b813 Mon Sep 17 00:00:00 2001 From: Anton Volnuhin Date: Tue, 30 May 2023 07:57:24 +0300 Subject: [PATCH] Switch once to onchange --- run_onchange_before_authorized_keys.sh | 0 ..._onchange_before_install_main_deps.sh.tmpl | 141 ++++++++++-------- 2 files changed, 79 insertions(+), 62 deletions(-) mode change 100644 => 100755 run_onchange_before_authorized_keys.sh rename run_once_before_install_main_deps.sh.tmpl => run_onchange_before_install_main_deps.sh.tmpl (64%) diff --git a/run_onchange_before_authorized_keys.sh b/run_onchange_before_authorized_keys.sh old mode 100644 new mode 100755 diff --git a/run_once_before_install_main_deps.sh.tmpl b/run_onchange_before_install_main_deps.sh.tmpl similarity index 64% rename from run_once_before_install_main_deps.sh.tmpl rename to run_onchange_before_install_main_deps.sh.tmpl index a795692..0515c03 100644 --- a/run_once_before_install_main_deps.sh.tmpl +++ b/run_onchange_before_install_main_deps.sh.tmpl @@ -1,9 +1,16 @@ #!/usr/bin/env bash -BASE_PACKAGES="kitty-terminfo gpg git curl wget ripgrep fd-find unzip python3-pip htop fzf bat gawk" +BASE_PACKAGES="gpg curl wget git" +ACT_PACKAGES="ripgrep fd-find unzip htop fzf bat gawk" USER=$(whoami) Green='\033[0;32m' # Green NC='\033[0m' # No Color + + + + + + echo -e " @@ -12,7 +19,6 @@ $Green########################################################################## ## Update caches and upgrade packages ## ## ## ###############################################################################$NC" -sleep 3 {{ if eq .chezmoi.os "linux" -}} {{ if eq .chezmoi.osRelease.id "fedora" -}} @@ -23,6 +29,11 @@ sleep 3 sudo apt upgrade -y {{ end -}} + {{ else if .chezmoi.os "darwin" -}} + bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + brew update + brew upgrade -y + {{ end -}} @@ -38,58 +49,23 @@ sleep 3 {{ if eq .chezmoi.os "linux" -}} {{ if eq .chezmoi.osRelease.id "fedora" -}} - sudo dnf install $BASE_PACKAGES util-linux-user -y + sudo dnf install $BASE_PACKAGES kitty-terminfo util-linux-user -y {{ else if eq .chezmoi.osRelease.id "debian" "ubuntu" -}} - sudo apt install $BASE_PACKAGES -y + sudo apt install $BASE_PACKAGES kitty-terminfo -y + + {{ else if eq .chezmoi.os "darwin" -}} + brew install $BASE_PACKAGES {{ end -}} {{ end -}} -echo -e " - - -$Green################################################################################ -## ## -## Install fish and set it as the default shell ## -## ## -################################################################################$NC" -sleep 3 - +################################################################################ +################################################################################ {{ if eq .chezmoi.os "linux" -}} - {{ if eq .chezmoi.osRelease.id "fedora" -}} - sudo dnf install fish -y - - {{ else if eq .chezmoi.osRelease.id "debian" "ubuntu" -}} - - {{ if eq .chezmoi.osRelease.id "debian" -}} - ## Setup fish repo in debian - VERS={{ .chezmoi.osRelease.versionID }} - echo "deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_$VERS/ /" | sudo tee /etc/apt/sources.list.d/shells:fish:release:3.list - curl -fsSL "https://download.opensuse.org/repositories/shells:fish:release:3/Debian_$VERS/Release.key" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/shells_fish_release_3.gpg > /dev/null - - {{ else -}} - ## Setup fish repo in ubuntu - sudo apt-add-repository ppa:fish-shell/release-3 -y - {{ end -}} - - ## Update repos with fish repo included and install fish - sudo apt update - sudo apt install fish -y - - {{ end -}} -{{ end -}} - -## Install fisher plugin manager for fish, so that we may update in after plugin list sync by chezmoi -fish -c "curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher" - -## Change default shell to fish -echo -echo -echo "Changing shell to fish for user $USER" -sudo chsh -s $(which fish) $USER - +if ! type nix &> /dev/null +then echo -e " @@ -98,42 +74,83 @@ $Green########################################################################## ## Install nix packet manager (single user) ## ## ## ###############################################################################$NC" + sleep 3 + bash <(curl -L https://nixos.org/nix/install) --no-daemon +fi +{{ end -}} + + +################################################################################ +################################################################################ + +{{ if eq .chezmoi.osRelease.id "debian" "ubuntu" -}} +if ! type fish &> /dev/null +then +echo -e " + + +$Green################################################################################ +## ## +## Subscribe to Fish shell repositories in ubuntu/debian ## +## ## +################################################################################$NC" sleep 3 -bash <(curl -L https://nixos.org/nix/install) --no-daemon + + {{ if eq .chezmoi.osRelease.id "debian" -}} + ## Setup fish repo in debian + VERS={{ .chezmoi.osRelease.versionID }} + echo "deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_$VERS/ /" | sudo tee /etc/apt/sources.list.d/shells:fish:release:3.list + curl -fsSL "https://download.opensuse.org/repositories/shells:fish:release:3/Debian_$VERS/Release.key" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/shells_fish_release_3.gpg > /dev/null + + {{ else -}} + ## Setup fish repo in ubuntu + sudo apt-add-repository ppa:fish-shell/release-3 -y + {{ end -}} +fi +{{ end -}} + + echo -e " $Green############################################################################### ## ## -## Install neovim ## +## Install neovim, fish, fisher, atuin, jump, and the rest of packages ## ## ## ###############################################################################$NC" sleep 3 {{ if eq .chezmoi.os "linux" -}} {{ if eq .chezmoi.osRelease.id "fedora" -}} - sudo dnf install neovim -y + sudo dnf install neovim fish $ACT_PACKAGES -y + nix-env -iA nixpkgs.atuin nixpkgs.jump {{ else if eq .chezmoi.osRelease.id "debian" "ubuntu" -}} - fish -c "nix-env -iA nixpkgs.neovim" + sudo apt install fish $ACT_PACKAGES -y + nix-env -iA nixpkgs.neovim nixpkgs.jump + bash <(curl https://raw.githubusercontent.com/ellie/atuin/main/install.sh) + + {{ else if eq .chezmoi.os "darwin" -}} + brew install fish neovim $ACT_PACKAGES atuin jump -y {{ end -}} {{ end -}} -echo -e " +## Install fisher plugin manager for fish, so that we may update in after plugin list sync by chezmoi +if ! fish -c fisher &>/dev/null +then + fish -c "curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher" +fi -$Green############################################################################### -## ## -## Install atuin and jump ## -## ## -###############################################################################$NC" -sleep 3 - -{{ if eq .chezmoi.os "linux" -}} - fish -c "nix-env -iA nixpkgs.atuin" - fish -c "nix-env -iA nixpkgs.jump" -{{ end -}} +## Change default shell to fish +if [ "$(basename $SHELL)" != "fish" ] +then + echo + echo + echo "Changing shell to fish for user $USER" + sudo chsh -s $(which fish) $USER +fi