diff --git a/.chezmoidata/packages.yaml b/.chezmoidata/packages.yaml new file mode 100644 index 0000000..40da855 --- /dev/null +++ b/.chezmoidata/packages.yaml @@ -0,0 +1,26 @@ +packages: + darwin: + brews: + - git + - curl + - fish + linux: + apts: + - git + - curl + - bash + - fish + apks: + - git + - curl + - bash + - fish + webman: + pkgs: + - bat + - lsd + - fzf + - zellij + - nvim + groups: + - modern-unix diff --git a/run_once_after_install.sh.tmpl b/run_once_after_install.sh.tmpl new file mode 100644 index 0000000..565d314 --- /dev/null +++ b/run_once_after_install.sh.tmpl @@ -0,0 +1,76 @@ +#!/usr/bin/env sh + +echo "[-] Running installation script [-]" + +{{- if eq .chezmoi.os "linux" }} +{{- if eq .chezmoi.osRelease.id "alpine" }} + +echo "Alpine Linux detected" +{{- else if (eq .chezmoi.osRelease.id "debian" "ubuntu" "zorin") }} + +echo "Debian-based Linux detected" +echo "\n[-] Adding fish package repository [-]" +sudo apt-add-repository ppa:fish-shell/release-3 +sudo apt install -y fish + +{{- else }} +echo "Linux OS release not recognized" +exit 1 +{{- end }} + +echo "\n[-] Downloading Nerd Fonts [-]" +if test -f ~/.fonts/GeistMonoNerdFontMono-Regular.otf; then + echo "GeistMono already installed" +else + curl -L -O https://github.com/ryanoasis/nerd-fonts/releases/latest/download/GeistMono.zip && \ + unzip GeistMono.zip -d ~/.fonts && \ + rm GeistMono.zip && \ + fc-cache -fv || \ + echo "Failed to download GeistMono.zip" +fi + +echo "\n[-] Setting default shell to fish [-]" +chsh -s $(which fish) || echo "chsh failed" + +{{- else if eq .osid "darwin" }} + +echo "macOS detected" +echo "\n[-] Setting default shell to fish [-]" +chsh -s $(which fish) || echo "chsh failed" + +{{- end }} + +echo "\n[-] Installing webman [-]" +if test -x ~/.webman/bin/webman; then + echo "webman already installed" +else + curl https://raw.githubusercontent.com/candrewlee14/webman/main/scripts/install.sh | sh +fi + +echo "\n[-] Installing nvim [-]" +if test -x ~/.webman/bin/nvim; then + echo "nvim already installed" +else + ~/.webman/bin/webman add nvim +fi + +echo "\n[-] Running fish install setup [-]" +/usr/bin/env fish ~/.config/fish/.on_install.fish + +echo "\n[-] Installing AstroNvim [-]" +if test -f ~/.config/nvim/config.ld ; then + echo "Already installed AstroNvim" +else + if test -d ~/.config/nvim/ ; then + echo "Moving current nvim config to nvim.bak" + mv ~/.config/nvim ~/.config/nvim.bak || echo "" + fi + git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/nvim + git clone https://github.com/candrewlee14/astronvim_config ~/.config/nvim/lua/user + + if test -x ~/.webman/bin/nvim ; then + ~/.webman/bin/nvim --headless +q + else + echo "~/.webman/bin/nvim does not exist or is not executable" + fi +fi diff --git a/run_once_install.sh.tmpl b/run_once_install.sh.tmpl deleted file mode 100644 index 6f89ce7..0000000 --- a/run_once_install.sh.tmpl +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env sh -echo "Running installation script\n" -{{- if eq .chezmoi.os "linux" }} -{{- if eq .chezmoi.osRelease.id "alpine" }} -apk update -apk add curl bash fish grep -{{- else if (eq .chezmoi.osRelease.id "debian" "ubuntu" "zorin") }} -sudo apt-add-repository ppa:fish-shell/release-3 -sudo apt update -sudo apt install curl bash fish -y -{{- else }} -echo "Linux OS release not recognized" -exit 1 -{{- end }} -chsh -s $(which fish) || echo "chsh failed" -{{- else if eq .osid "darwin" }} -brew install curl fish bash -chsh -s $(which fish) || echo "chsh failed" -{{- end }} - -curl https://raw.githubusercontent.com/candrewlee14/webman/main/scripts/install.sh | sh -~/.webman/bin/webman group add modern-unix --all || echo "Not all modern-unix packages installed successfully" -~/.webman/bin/webman add fzf || echo "fzf install failed" -~/.webman/bin/webman add zellij || echo "zellij install failed" -~/.webman/bin/webman add nvim || echo "nvim install failed" - -/usr/bin/env fish ~/.config/fish/.on_install.fish - -if test -x ~/.config/nvim/; then - echo "Moving current nvim config to nvim.bak" - mv ~/.config/nvim ~/.config/nvim.bak || echo "" -fi -echo "Installing AstroNvim config" -git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/nvim -git clone https://github.com/candrewlee14/astronvim_config ~/.config/nvim/lua/user - -if test -x ~/.webman/bin/nvim; then - ~/.webman/bin/nvim --headless +q -else - echo "~/.webman/bin/nvim does not exist or is not executable" -fi diff --git a/run_onchange_install-packages.sh.tmpl b/run_onchange_install-packages.sh.tmpl new file mode 100644 index 0000000..e1bc745 --- /dev/null +++ b/run_onchange_install-packages.sh.tmpl @@ -0,0 +1,47 @@ +#!/usr/bin/env sh + +# .chezmoidata/packages.yaml hash: {{ include ".chezmoidata/packages.yaml" | sha256sum }} + +echo "[-] Updating packages [-]" + +{{- if eq .chezmoi.os "linux" }} +{{- if eq .chezmoi.osRelease.id "alpine" }} +echo "[-] Updating APK packages [-]" +apk update +{{ range .packages.linux.apks -}} +apk add {{ . | quote }} +{{ end -}} +{{- else if (eq .chezmoi.osRelease.id "debian" "ubuntu" "zorin") }} +echo "[-] Updating Apt packages [-]" +sudo apt update +{{ range .packages.linux.apts -}} +sudo apt install -y {{ . | quote }} +{{ end -}} +{{ end -}} + +{{- else if eq .osid "darwin" }} +echo "[-] Updating brews [-]" +{{ range .packages.darwin.brews -}} +brew install {{ . | quote }} +{{ end -}} +{{ end -}} + +echo "[-] Updating Webman groups [-]" + +if test -x ~/.webman/bin/webman; then + echo "webman already installed" +else + echo "\n[-] Installing webman [-]" + curl https://raw.githubusercontent.com/candrewlee14/webman/main/scripts/install.sh | sh +fi + +~/.webman/bin/webman upgrade webman + +{{ range .packages.webman.groups -}} +~/.webman/bin/webman group upgrade {{ . | quote }} -a +{{ end -}} + +echo "[-] Updating Webman packages [-]" +{{ range .packages.webman.pkgs -}} +~/.webman/bin/webman upgrade {{ . | quote }} +{{ end -}} \ No newline at end of file