From ee2bf027723f702b2a34472682be5cadb0fbba39 Mon Sep 17 00:00:00 2001 From: reeink Date: Sun, 3 Mar 2024 21:41:52 +0800 Subject: [PATCH] add auto-install scripts for fedora39 --- .chezmoidata/packages.toml | 14 +++++++ .../run_onchange_fedora-install-pkgs.sh.tmpl | 40 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .chezmoidata/packages.toml create mode 100644 .chezmoiscripts/run_onchange_fedora-install-pkgs.sh.tmpl diff --git a/.chezmoidata/packages.toml b/.chezmoidata/packages.toml new file mode 100644 index 0000000..44c1323 --- /dev/null +++ b/.chezmoidata/packages.toml @@ -0,0 +1,14 @@ +[packages.fedora39] +dnf.pkgs = [ + "eza", + "thefuck", + "micromamba", + "zoxide" +] +brew.pkgs = [ + "atuin", + "fnm", + "yazi", + "zsh-syntax-highlighting", + "zsh-autosuggestions" +] diff --git a/.chezmoiscripts/run_onchange_fedora-install-pkgs.sh.tmpl b/.chezmoiscripts/run_onchange_fedora-install-pkgs.sh.tmpl new file mode 100644 index 0000000..2c27251 --- /dev/null +++ b/.chezmoiscripts/run_onchange_fedora-install-pkgs.sh.tmpl @@ -0,0 +1,40 @@ +{{- if (and (and (eq .chezmoi.os "linux") +(eq .chezmoi.osRelease.id "fedora")) +(eq .chezmoi.osRelease.versionID "39")) -}} +#!/bin/bash +# fedora39 packages hash: {{ .packages.fedora39 | quote | sha256sum }} + +bold=$(tput bold) +normal=$(tput sgr0) +function custom_echo() { + echo -e "${bold}$1${normal}" +} + +{{ if gt (len .packages.fedora39.dnf.pkgs) 0 -}} +# Install dnf packages +custom_echo "[Info] Installing dnf packages... Please input your password if requested." +sudo dnf install {{ range .packages.fedora39.dnf.pkgs }} {{- . | quote }} {{ end }} +{{- end }} + +{{ if gt (len .packages.fedora39.brew.pkgs) 0 -}} +# Check if Homebrew is installed +if ! command -v brew &> /dev/null; then + custom_echo "[Info] Homebrew is not installed. Installing..." + # Install Homebrew + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + # Check if installation was successful + if ! command -v brew &> /dev/null; then + custom_echo "[Error] Failed to install Homebrew. Exiting." + exit 1 + fi + custom_echo "[Success] Homebrew has been successfully installed." +else + custom_echo "[Info] Homebrew is already installed." +fi + +# Install Homebrew packages +custom_echo "[Info] Installing homebrew packages..." +brew install {{ range .packages.fedora39.brew.pkgs }} {{- . | quote }} {{ end }} +{{- end }} + +{{- end }}