Motivating use-case:
j0rge on the Universal Blue Discord:
plus if I could put my CLI and GUI apps in one Brewfile, check it into github and I’d be done
I have no knowledge of (or interest in) Ruby, so I’m not gonna figure out the ideal solution of listing Flatpak apps in the Brewfile; instead, as a “dirty hack”/“preliminary prototype” I have my Homebrew packages in my Brewfile and my Flatpak apps in a separate file (which I’m calling “Flatpakfile”) which I sync with GitHub via chezmoi. Here’s the lazy-ish UX:
- Every time I log in, systemd automatically runs a user service named flatpak-dump.service which updates
~/.Flatpakfile
according to the list of installed Flatpak apps on your system. As a treat, systemd also automatically runs a user service named homebrew-dump.service which updates~/.Brewfile
according to the list of installed Homebrew packages on your system. - It’s up to you how to manage your
~/.Flatpakfile
and~/.Brewfile
. I personally have them tracked in chezmoi, so changes to them show up in my local chezmoi git repo whenever I runchezmoi re-add
, at which point I can commit and push those changes to my GitHub dotfiles repo. I might eventually add a systemd user service to automatically runchezmoi re-add
afterhomebrew-dump.service
andflatpak-dump.service
, I haven’t decided yet. - When you’ve made changes to your
~/.Flatpakfile
or~/.Brewfile
(e.g. from achezmoi apply
) and you want to install any new packages from those files, you can just runsystemctl --user start flatpak-install.service
(defined here) orsystemctl --user start homebrew-install.service
(defined here), respectively. If you want to run those services on an automatic schedule, you can define corresponding systemd timer units; I haven’t done that yet because I haven’t thought about any potential feedback loops I might cause if I’m careless in setting up automation triggers/schedules.
Caveat: currently, if you’ve manually removed packages from your Flatpakfile or Brewfile, you’ll need to manually uninstall them directly via flatpak
or homebrew
. But maybe I can throw together a simple script which diffs the state of the Flatpakfile/Brewfile with the actual list of installed Flatpak apps/Homebrew packages and then uninstalls any Flatpak apps/Homebrew packages not listed in the Flatpakfile/Brewfile…that way, Flatpakfile and Brewfile would provide an approximately declarative UX. If at least one other person here is interested in using that functionality, I’ll try implementing it.