Files
omarchycn/migrations/1785013000.sh
T
David Heinemeier HanssonandClaude Opus 5 171b6374c6 Keep the zram fallback until its replacement is installed
zram-generator creates no device at all when nothing configures one, so the
/etc copy is the only thing holding up swap until the vendor drop-in lands.
Removing it early costs a machine its zram entirely, not just its tuning.

The update pipeline installs packages before it runs migrations, so a packaged
machine always has the drop-in by then. A dev checkout does not: omarchy-update-dev
pulls migrations from a release the installed package has never seen, and no
ordering of the pipeline can produce a file that has not been built yet.
Checking for the drop-in is what makes the removal safe rather than well
sequenced.

The tests pinned the drop-in path to a fixture as well. Left at the real path
they would pass or fail on whether the machine running them happened to carry
the packaged copy.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-26 14:37:22 -07:00

37 lines
1.8 KiB
Bash

echo "Move zram tuning to a vendor drop-in"
zram_conf="${OMARCHY_ZRAM_CONF:-/etc/systemd/zram-generator.conf}"
zram_dropin="${OMARCHY_ZRAM_DROPIN:-/usr/lib/systemd/zram-generator.conf.d/90-omarchy.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
# Only once the replacement is on disk. zram-generator makes no device at all
# when nothing configures one, so until the drop-in lands the /etc copy is the
# only thing standing between this machine and no zram swap. The update pipeline
# installs packages before it runs migrations, but a dev checkout carries
# migrations from a release the installed package does not have yet.
[[ -f $zram_dropin ]] || 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