From c4dbf12920ba91f0bcb04849b774c69ca70d39a7 Mon Sep 17 00:00:00 2001 From: Ty Smith Date: Mon, 11 May 2026 01:19:12 -0700 Subject: [PATCH] Add pre-refresh-pacman.d hooks for custom repository support (#5681) Fires after the channel template is copied to /etc/pacman.conf and before `pacman -Syyuu` runs, letting users layer custom Pacman repositories or IgnorePkg directives onto the freshly-written config so they're respected by the upgrade. Useful for users running on overlay distros (CachyOS, Chaotic-AUR, internal company repos) where a wipe-and-reinstall would otherwise pull vanilla Arch versions. Ships with `pre-refresh-pacman.d/add-custom-repo.sample` showing the pattern. Co-authored-by: Claude Opus 4.7 (1M context) --- bin/omarchy-refresh-pacman | 3 +++ .../add-custom-repo.sample | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 config/omarchy/hooks/pre-refresh-pacman.d/add-custom-repo.sample 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"