mackup icon indicating copy to clipboard operation
mackup copied to clipboard

Possible to do a brew bundle export?

Open jmuchovej opened this issue 5 years ago • 5 comments

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?

  • brew is trying to support Linux. I think strictly supporting brew might keep mackup from detrimentally expanding it's scope, while still maintaining a degree of platform agnosticism.
  • Brewfiles are easily exported from brew bundle, but they need to be generated. It's easy enough to write-up a script to do the exports, but mackup doesn't support Brewfiles, 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 Brewfile application that uses the "global" ~/.Brewfile that brew bundle supports. This shouldn't modify the behavior of mackup, it just adds Brewfile support.

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.cfg to 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 mackup provides a new command setup, which differs from mackup restore only in that it prompts the user about performing an action like brew bundle install --file=<file>. Honestly, this could just be a question asked by mackup restore.
  • Support Brewfile diff, 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 last Brewfile was dumped and do a brew bundle dump --file= if they have. Naïvely we could just ask to overwrite the Brewfile, I'm not not sure of the impact on how quickly mackup might be able to run a diff (since brew can 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 use brew on MacOS and Linux).
  • I have a personal preference towards maintaining as much XDG_CONFIG_HOME compliance 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_HOME as a preference.)
  • brew supports a global ~/.Brewfile which could also be a default that's used.
  • Then, of course, we could always let the user specify the file path in ~/.mackup.cfg

jmuchovej avatar Jan 14 '20 20:01 jmuchovej

@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.)

jmuchovej avatar Jan 14 '20 21:01 jmuchovej

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

jamiew avatar Jan 31 '20 16:01 jamiew

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 ~/.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'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.

jmuchovej avatar Jan 31 '20 16:01 jmuchovej

If the ~/.Brewfile is now officially supported, we can add it to the database for sure: Screen Shot 2020-02-26 at 9 27 07 PM

PR welcome!

lra avatar Feb 27 '20 02:02 lra

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?

krubenok avatar Dec 30 '21 17:12 krubenok