Possible to do a brew bundle export?
Broadly, adding official support for brew bundle
So glad I found this, handles quite a bit of what I've done with shell scripting. Apologies on the long post, I figured it would be easier to outline everything as much as possible. 😅
Inspiration / Background:
I've haphazardly automated some of my config backups and package installation, but mackup does a better job generalizing than I have, at least on the config side. 😀
Does it make sense for mackup to potentially support acting as a [rudimetnary] package exporter/installer?
brewis trying to support Linux. I think strictly supportingbrewmight keepmackupfrom detrimentally expanding it's scope, while still maintaining a degree of platform agnosticism.Brewfiles are easily exported frombrew bundle, but they need to be generated. It's easy enough to write-up a script to do the exports, butmackupdoesn't supportBrewfiles, period.
Preliminary thoughts on what supporting this might entail:
Naïvely (I currently do this with a local application file, in ~/.mackup):
- Just add a
Brewfileapplication that uses the "global"~/.Brewfilethatbrew bundlesupports. This shouldn't modify the behavior ofmackup, it just addsBrewfilesupport.
More nicely (a personal favorite)
- Support generating a "custom"
Brewfile(that is, it can be arbitrarily placed). This does like above, but I think would necessitate modifying~/.mackup.cfgto allow users to specify a particular location for this. Maybe something like...# ... # no attachment here, just based on the current directory structure [applications.Brewfile] # customization so that we can use a non-standard location path = "/path/to/Brewfile" # this could honestly just be a constant and we only allow for path modification file = "Brewfile" # ... - Support an actual system installation.
What I mean here is that
mackupprovides a new commandsetup, which differs frommackup restoreonly in that it prompts the user about performing an action likebrew bundle install --file=<file>. Honestly, this could just be a question asked bymackup restore. - Support
Brewfilediff, of some sort (I need to look into this further). The main idea here is to check whether or not they've installed any packages since the lastBrewfilewas dumped and do abrew bundle dump --file=if they have. Naïvely we could just ask to overwrite theBrewfile, I'm not not sure of the impact on how quicklymackupmight be able to run a diff (sincebrewcan sometimes take a minute).
Notes on specifying file locations:
- I don't think we really need to support specifying different filenames than
Brewfile(though this could be a hangup for people trying to usebrewon MacOS and Linux). - I have a personal preference towards maintaining as much
XDG_CONFIG_HOMEcompliance as possible, so a sensible default to me would be to place the Brewfile in~/.config/brew/Brewfile. (Opening another issue about globally preferring$XDG_CONFIG_HOMEas a preference.) brewsupports a global~/.Brewfilewhich could also be a default that's used.- Then, of course, we could always let the user specify the file path in
~/.mackup.cfg
@lra so, I just saw: #1291 – forgot to take a gander through PRs. 😅 i think it's definitely possible to consider this (~/.Brewfile) to be a globally accepted config. however, it's only used in a brew bundle install and brew bundle dump – this is less of a program config and more of an OS config, per se. (if that makes sense?)
It's not super clear, at least from what I've seen, that the explicit goal of mackup is just to manage program configurations, which is why I had hoped supporting brew-bundle might be a feasible thing to do. (definitely don't mind doing it, just wanted to raise the topic before putting dev time into it.)
I also sync my ~/.Brewfile with mackup via a custom .cfg file... doing the dump and restore automatically seems a little overkill, but I think it could be useful to revisit #1291.
I personally consider my ~/.Brewfile to functionally be my system-wide configuration for homebrew, in the same way I have configurations for specific apps
I personally consider my ~/.Brewfile to functionally be my system-wide configuration for
homebrew, in the same way I have configurations for specific apps
I don't think it makes much sense to care a lot about Brewfiles that aren't ~/.Brewfile. Mostly because homebrew doesn't support something analogous to a virtualenv. Kinda adding support for not really pursuing the dumping/restoring I was talking about.
I also sync my
~/.Brewfilewith mackup via a custom .cfg file... doing the dump and restore automatically seems a little overkill, but I think it could be useful to revisit #1291.
I'm currently doing the same with a custom .cfg. While I don't find adding a "dump/restore functionality" to be overkill, I could definitely see how/why it might not fit into the goals of mackup.
If the ~/.Brewfile is now officially supported, we can add it to the database for sure:

PR welcome!
If the ~/.Brewfile is now officially supported, we can add it to the database for sure
That location is the officially sanctioned place to read a "global" brew file, but it's not the default location that brew files get written to. By default it writes to "Brewfile" (no .) in whatever directory you're currently in. In practice, this means that means that most people's Brewfiles are probably located at ~/Brewfile and not ~/.Brewfile.
Bummer. Thoughts?