moonarch-pkgbuilds/moonarch-git/moonarch.install
nevaforget 31efc0f697 fix: clean up legacy user-level paru config on install/upgrade
transform.sh previously wrote [moonarch] to ~/.config/paru/paru.conf.
This silently overrides the system-level /etc/paru.conf, breaking
package resolution for moongreet-git, moonlock-git, moonset-git.
2026-04-07 11:20:19 +02:00

78 lines
3.4 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
# Ensure paru PKGBUILD repo is configured (breaks bootstrap loop otherwise)
PARU_CONF="/etc/paru.conf"
if [ -f "$PARU_CONF" ]; then
if ! grep -q 'Mode.*p' "$PARU_CONF" 2>/dev/null; then
sed -i '/^\[options\]/a Mode = arp' "$PARU_CONF"
fi
if ! grep -q '\[moonarch-pkgbuilds\]' "$PARU_CONF" 2>/dev/null; then
printf '\n[moonarch-pkgbuilds]\nUrl = https://gitea.moonarch.de/nevaforget/moonarch-pkgbuilds.git\n' \
>> "$PARU_CONF"
fi
fi
# Cleanup legacy user-level paru config (moved to /etc/paru.conf)
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
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
echo "==> Moonarch defaults installed."
echo "==> For first-time setup run: /opt/moonarch/scripts/post-install.sh"
echo "==> This enables services, configures firewall, and sets up user defaults."
}
post_upgrade() {
post_install
}