Ship zram tuning as a vendor drop-in

pacman checks file conflicts during transaction prepare, so the --overwrite
entry added alongside /etc/systemd/zram-generator.conf never got to run: the
copy of omarchy-update-system-pkgs driving the upgrade is the one already on
disk. Every machine carrying archinstall's copy aborted the transaction.

zram-generator.conf(5) reserves /etc for the local admin and has vendors ship
snippets under /usr/lib/systemd/zram-generator.conf.d/, where drop-ins outrank
the main config file. Nothing collides, and the tuning wins whether or not
archinstall's file is still around.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LjeyQZsNBxqyYy9z8KaKm7
This commit is contained in:
David Heinemeier Hansson
2026-07-25 14:01:38 -07:00
co-authored by Claude Opus 5
parent ec59ac70f8
commit 2e04f093c1
7 changed files with 122 additions and 2 deletions
+28
View File
@@ -0,0 +1,28 @@
echo "Move zram tuning to a vendor drop-in"
zram_conf="${OMARCHY_ZRAM_CONF:-/etc/systemd/zram-generator.conf}"
# The tuning ships as /usr/lib/systemd/zram-generator.conf.d/90-omarchy.conf.
# Drop-ins outrank the main config file, so a leftover /etc copy decides nothing
# and only implies /etc is where zram gets configured.
[[ -f $zram_conf ]] || exit 0
# Package-owned copies go away with their package on upgrade.
pacman -Qo "$zram_conf" &>/dev/null && exit 0
# archinstall writes exactly a [zram0] section with one compression-algorithm
# line. Anything else is a deliberate local override. grep exits 1 on a config
# that sets nothing at all, which omarchy-migrate's -e would take as a failed
# migration and block every migration behind this one.
settings=$(grep -vE '^[[:space:]]*([#;]|$)' "$zram_conf" | tr -d '[:space:]') || true
if [[ -z $settings || $settings =~ ^\[zram0\]compression-algorithm=[[:alnum:]-]+$ ]]; then
# A refused sudo just leaves the file for next time; tidying is not worth
# failing the migration chain over.
sudo rm -f "$zram_conf" || true
else
echo "Keeping $zram_conf; it has local edits."
echo "Omarchy's drop-in overrides it. Move your changes to"
echo "/etc/systemd/zram-generator.conf.d/99-local.conf to keep them in effect."
fi