diff --git a/bin/omarchy-refresh-pacman b/bin/omarchy-refresh-pacman index fce99ee5..73ff9054 100755 --- a/bin/omarchy-refresh-pacman +++ b/bin/omarchy-refresh-pacman @@ -19,5 +19,8 @@ echo sudo cp -f "$OMARCHY_PATH/default/pacman/pacman-$channel.conf" /etc/pacman.conf sudo cp -f "$OMARCHY_PATH/default/pacman/mirrorlist-$channel" /etc/pacman.d/mirrorlist +# Allow user customization of /etc/pacman.conf before the upgrade runs +omarchy-hook pre-refresh-pacman + # Reset all package DBs and then update sudo pacman -Syyuu --noconfirm diff --git a/config/omarchy/hooks/pre-refresh-pacman.d/add-custom-repo.sample b/config/omarchy/hooks/pre-refresh-pacman.d/add-custom-repo.sample new file mode 100644 index 00000000..cebec4fc --- /dev/null +++ b/config/omarchy/hooks/pre-refresh-pacman.d/add-custom-repo.sample @@ -0,0 +1,24 @@ +#!/bin/bash + +# This hook is called by `omarchy refresh pacman` AFTER the channel template +# is copied to /etc/pacman.conf and BEFORE `pacman -Syyuu` runs. Use it to +# layer customizations onto the freshly-written pacman.conf so they're +# respected by the upgrade — common cases are adding a custom repository +# (e.g. CachyOS, Chaotic-AUR, an internal company repo) or extra IgnorePkg +# lines. +# +# The hook runs as the invoking user with a warm sudo cache. +# +# To put it into use, remove .sample from this file name. + +# Example: add an Include line above [core] for a custom repo. +# Maintain the repo entries in /etc/pacman.d/custom-repos.conf yourself. + +CONF=/etc/pacman.conf +SNIPPET=/etc/pacman.d/custom-repos.conf +MARKER="Include = $SNIPPET" + +[[ -r $SNIPPET ]] || exit 0 +grep -qxF "$MARKER" "$CONF" && exit 0 + +sudo sed -i "0,/^\[core\]/s||$MARKER\n\n[core]|" "$CONF"