Files
connor 55a2c59645 pkg-snapshot: record user-scope flatpaks too
Moonlight went on the work laptop as a flatpak, which neither apt-mark nor
pacman can see — so a rebuild from the manifests would have silently left
it out. pkg-restore adds the flathub user remote before installing, since
Ubuntu ships flathub as a system remote that --user cannot resolve.

System-scope flatpaks are deliberately not recorded: those belong to
whoever administers the machine, not to these dotfiles.
2026-09-14 15:51:14 -04:00

32 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Record what is installed on this machine, into packages/<hostname>.*
# Run it after installing something worth keeping, then commit the diff.
# The diff doubles as a log of what you added and when.
set -euo pipefail
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
HOST="${DOTFILES_HOST:-$(uname -n | tr '[:upper:]' '[:lower:]')}"
OUT="${REPO}/packages"
mkdir -p "$OUT"
if command -v pacman >/dev/null 2>&1; then
pacman -Qqen | LC_ALL=C sort > "${OUT}/${HOST}.pacman"
pacman -Qqem | LC_ALL=C sort > "${OUT}/${HOST}.aur"
echo "wrote ${HOST}.pacman ($(wc -l < "${OUT}/${HOST}.pacman")) and ${HOST}.aur ($(wc -l < "${OUT}/${HOST}.aur"))"
elif command -v apt-mark >/dev/null 2>&1; then
apt-mark showmanual | LC_ALL=C sort > "${OUT}/${HOST}.apt"
echo "wrote ${HOST}.apt ($(wc -l < "${OUT}/${HOST}.apt"))"
else
echo "pkg-snapshot: no pacman or apt-mark on this machine" >&2; exit 1
fi
# Flatpaks are invisible to both package managers, so record them separately.
# User-scope only: system-scope flatpaks belong to whoever administers the box.
if command -v flatpak >/dev/null 2>&1; then
flatpak list --app --user --columns=application 2>/dev/null | LC_ALL=C sort > "${OUT}/${HOST}.flatpak"
if [[ -s "${OUT}/${HOST}.flatpak" ]]; then
echo "wrote ${HOST}.flatpak ($(wc -l < "${OUT}/${HOST}.flatpak"))"
else
rm -f "${OUT}/${HOST}.flatpak"
fi
fi