#!/usr/bin/env bash set -euo pipefail # Populate the keyring in the built root from the keyring bundles # (/usr/share/pacman/keyrings, incl. the copied cachyos keyring). # This mirrors the guide; it runs inside the image you are making. # pacman-key --populate needs no network. pacman-key --init pacman-key --populate archlinux cachyos chaotic # Restore the strict live /etc/pacman.conf after pacstrap installs the # 'pacman' package, which ships a stock /etc/pacman.conf and would otherwise # overwrite this directory's configured version. install -m 0644 /root/.live-pacman.conf /etc/pacman.conf rm -f /root/.live-pacman.conf # ============================================================================ # Pre-install dotfile dependencies into /etc/skel so new users get them # instantly on first login (no network required). # ============================================================================ SKEL="/etc/skel" # ── Oh-My-Zsh ──────────────────────────────────────────────────────────────── if [[ ! -d "${SKEL}/.oh-my-zsh" ]]; then echo "[customize] Cloning Oh-My-Zsh into skel..." git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "${SKEL}/.oh-my-zsh" fi # Oh-My-Zsh custom plugins ZSH_CUSTOM="${SKEL}/.oh-my-zsh/custom" mkdir -p "${ZSH_CUSTOM}/plugins" declare -A OMZ_PLUGINS=( [zsh-history-substring-search]="https://github.com/zsh-users/zsh-history-substring-search.git" [zsh-autosuggestions]="https://github.com/zsh-users/zsh-autosuggestions.git" [zsh-eza]="https://github.com/z-shell/zsh-eza.git" [fzf-zsh-plugin]="https://github.com/unixorn/fzf-zsh-plugin.git" [zsh-syntax-highlighting]="https://github.com/zsh-users/zsh-syntax-highlighting.git" [zsh-autocomplete]="https://github.com/marlonrichert/zsh-autocomplete.git" ) for plugin in "${!OMZ_PLUGINS[@]}"; do target="${ZSH_CUSTOM}/plugins/${plugin}" if [[ ! -d "${target}" ]]; then echo "[customize] Cloning OMZ plugin: ${plugin}" git clone --depth=1 "${OMZ_PLUGINS[${plugin}]}" "${target}" fi done # ── LazyVim (lazy.nvim bootstraps on first launch, but pre-clone the plugin) ─ NVIM_DATA="${SKEL}/.local/share/nvim" mkdir -p "${NVIM_DATA}" if [[ ! -d "${NVIM_DATA}/lazy/lazy.nvim" ]]; then echo "[customize] Pre-cloning lazy.nvim for LazyVim..." git clone --filter=blob:none --branch=stable \ https://github.com/folke/lazy.nvim.git "${NVIM_DATA}/lazy/lazy.nvim" fi # ── Fish: ensure default shell is set for the live user ────────────────────── # The live user (usually 'archlinux' or 'root') gets fish as default shell if command -v fish &>/dev/null; then echo "[customize] Setting fish as default shell for skel..." chsh -s /usr/bin/fish root 2>/dev/null || true fi # ── Ensure skel directories have correct permissions ───────────────────────── chmod 700 "${SKEL}/.config" 2>/dev/null || true find "${SKEL}/.config" -type f -exec chmod 644 {} \; 2>/dev/null || true find "${SKEL}/.config" -type d -exec chmod 755 {} \; 2>/dev/null || true find "${SKEL}/.config" -name '*.sh' -exec chmod 755 {} \; 2>/dev/null || true find "${SKEL}/.local" -type d -exec chmod 755 {} \; 2>/dev/null || true echo "[customize] Dotfile pre-installation complete."