moonarch-pkgbuilds/moonarch-git/moonarch.install
nevaforget b4ee733827
All checks were successful
Build and publish packages / build-and-publish (push) Successful in 12s
feat(install): drop paru --pkgbuilds fallback, registry is the only path
The moonarch.install hook used to ensure /etc/paru.conf had Mode = arp
and a [moonarch-pkgbuilds] section. Both exist to let paru resolve
moonarch packages from a PKGBUILD repo — a second mechanism parallel
to the Arch registry, redundant now that the registry DB is stable.

Hook now strips the legacy config on next upgrade. Bump pkgrel so every
installed system picks up the cleanup.
2026-04-20 14:19:01 +02:00

103 lines
4.7 KiB
Plaintext

# ABOUTME: Post-install hooks for moonarch-git package.
# ABOUTME: Handles zsh integration and configs owned by other packages.
post_install() {
# Zsh integration: source moonarch defaults for users without ~/.zshrc
if ! grep -q "zshrc.moonarch" /etc/zsh/zshrc 2>/dev/null; then
echo '# Moonarch defaults (overridden by ~/.zshrc)' >> /etc/zsh/zshrc
echo '[[ ! -f "$HOME/.zshrc" ]] && source /etc/zsh/zshrc.moonarch' >> /etc/zsh/zshrc
fi
# Deploy greetd config (file owned by greetd package, overwrite deliberately)
if [ -d /etc/greetd ]; then
cp /usr/share/moonarch/greetd/config.toml /etc/greetd/config.toml
cp /usr/share/moonarch/greetd/niri-greeter.kdl /etc/greetd/niri-greeter.kdl
fi
# Deploy moongreet config (file owned by moongreet-git, overwrite deliberately)
if [ -d /etc/moongreet ]; then
cp /usr/share/moonarch/moongreet/moongreet.toml /etc/moongreet/moongreet.toml
fi
# Deploy foot config (file owned by foot package, overwrite deliberately)
cp /usr/share/moonarch/foot/foot.ini /etc/xdg/foot/foot.ini
# Deploy waybar style (file owned by waybar package, overwrite deliberately)
cp /usr/share/moonarch/waybar/style.css /etc/xdg/waybar/style.css
# Deploy swaync config (files owned by swaync package, overwrite deliberately)
cp /usr/share/moonarch/swaync/config.json /etc/xdg/swaync/config.json
cp /usr/share/moonarch/swaync/style.css /etc/xdg/swaync/style.css
# Deploy Walker config override to skel and existing user homes.
# Only copies if user has no config yet — never overwrites manual edits.
install -Dm644 /usr/share/moonarch/walker-config.toml \
/etc/skel/.config/walker/config.toml
while IFS=: read -r _ _ uid gid _ home _; do
if [ "$uid" -ge 1000 ] && [ "$uid" -lt 60000 ] && [ -d "$home" ]; then
if [ ! -f "$home/.config/walker/config.toml" ]; then
install -Dm644 -o "$uid" -g "$gid" /usr/share/moonarch/walker-config.toml \
"$home/.config/walker/config.toml"
fi
fi
done < /etc/passwd
# Clean up legacy paru PKGBUILD-repo config. Moonarch now ships binaries
# exclusively through the Arch registry (pacman repo in /etc/pacman.conf);
# the [moonarch-pkgbuilds] section and Mode = arp are obsolete.
PARU_CONF="/etc/paru.conf"
if [ -f "$PARU_CONF" ]; then
sed -i '/^Mode[[:space:]]*=[[:space:]]*arp\s*$/d' "$PARU_CONF"
sed -i '/^\[moonarch-pkgbuilds\]$/,/^$/d' "$PARU_CONF"
fi
# Cleanup legacy user-level configs (moved to system-level)
while IFS=: read -r _ _ uid _ _ home _; do
if [ "$uid" -ge 1000 ] && [ "$uid" -lt 60000 ] && [ -d "$home" ]; then
rm -f "$home/.config/paru/paru.conf" 2>/dev/null || true
rmdir "$home/.config/paru" 2>/dev/null || true
for svc in cliphist kanshi nautilus walker; do
rm -f "$home/.config/systemd/user/${svc}.service" 2>/dev/null || true
rm -f "$home/.config/systemd/user/graphical-session.target.wants/${svc}.service" 2>/dev/null || true
done
fi
done < /etc/passwd
# Cleanup legacy /usr/local/bin/ scripts from pre-package installs
rm -f /usr/local/bin/moonarch-* 2>/dev/null || true
rm -f /usr/local/bin/swww /usr/local/bin/swww-daemon 2>/dev/null || true
rm -f /usr/local/bin/moonarch-update 2>/dev/null || true
# Battery conservation mode: create state directory and enable restore service
install -dm775 -g wheel /var/lib/moonarch
if [ -f /sys/class/power_supply/BAT0/charge_control_end_threshold ]; then
systemctl enable moonarch-batsaver.service 2>/dev/null || true
fi
echo "==> Moonarch defaults installed."
echo "==> For first-time setup run: /opt/moonarch/scripts/post-install.sh"
echo "==> This enables services and configures firewall."
}
pre_upgrade() {
# Remove untracked walker theme files from pre-package manual deploys.
# Without this, pacman refuses to overwrite files it doesn't own.
if [ -d /etc/xdg/walker/themes/moonarch ] && ! pacman -Qo /etc/xdg/walker/themes/moonarch/style.css &>/dev/null; then
rm -rf /etc/xdg/walker/themes/moonarch
fi
# Migrate cliphist.service → cliphist-text + cliphist-image
if [ -f /etc/systemd/user/cliphist.service ]; then
while IFS=: read -r _ _ uid _ _ home _; do
if [ "$uid" -ge 1000 ] && [ "$uid" -lt 60000 ] && [ -d "$home" ]; then
rm -f "$home/.config/systemd/user/graphical-session.target.wants/cliphist.service" 2>/dev/null || true
fi
done < /etc/passwd
rm -f /etc/systemd/user/graphical-session.target.wants/cliphist.service 2>/dev/null || true
fi
}
post_upgrade() {
post_install
}