Files
dotfiles/.chezmoiscripts/run_onchange_before_10-install-packages.sh.tmpl
T
2026-04-22 13:33:48 +03:00

53 lines
1.1 KiB
Cheetah
Executable File

#!/bin/bash
{{ if eq .chezmoi.osRelease.id "nixos" }}
exit 0
{{ end }}
set -euo pipefail
echo "Installing packages..."
{{ if or (eq .chezmoi.osRelease.id "arch") (eq .chezmoi.osRelease.id "cachyos") }}
sudo pacman -Sy --noconfirm
pkgs=()
{{ range .packages.arch }}
if ! pacman -Q "{{ . }}" &>/dev/null; then
pkgs+=("{{ . }}")
fi
{{ end }}
if [[ ${#pkgs[@]} -gt 0 ]]; then
echo "Installing pacman packages..."
sudo pacman -S --noconfirm --needed "${pkgs[@]}"
fi
# Install paru
if command -v paru >/dev/null 2>&1; then
echo "Paru is already installed."
else
sudo pacman -S --noconfirm --needed git base-devel
build_dir="$HOME/.cache/chezmoi-paru-build"
rm -rf "$build_dir"
mkdir -p "$build_dir"
git clone https://aur.archlinux.org/paru.git "$build_dir"
makepkg --dir "$build_dir" -si --noconfirm
rm -rf "$build_dir"
fi
# Install AUR pkgs
aur_pkgs=()
{{ range .packages.aur }}
if ! pacman -Q "{{ . }}" &>/dev/null; then
aur_pkgs+=("{{ . }}")
fi
{{ end }}
if [[ ${#aur_pkgs[@]} -gt 0 ]]; then
echo "Installing AUR packages"
paru -S --noconfirm --needed "${aur_pkgs[@]}"
fi
{{ end }}
echo "Done"