holman / dotfiles

@holman does dotfiles
http://zachholman.com/2010/08/dotfiles-are-meant-to-be-forked/
MIT License
7.24k stars 3.35k forks source link

Question: `brew install` commands in install.sh #338

Open bradical opened 3 years ago

bradical commented 3 years ago

Would you expect this to work? I'm a little unclear on the order of things and whether brew would be available at the time. My example is something like:

postgresql/install.sh

brew install postgresql; brew services start postgresql

Wasn't sure if there was a better technique for installing a bunch of brew things as part of install

Still digging these years later. Thanks!

holman commented 3 years ago

I think so? I think the bootstrap gets run first, and then install scripts get run separately afterwards, so brew should be around at that point.

bradical commented 3 years ago

is that how you would recommend doing it or is there some other way to handle installing brew packages on setup? seemed like you might have done something else in the past and the moved away from it?

holman commented 3 years ago

I think I had some casks set up for installing macOS apps, but moved away from that. But yeah, I'd do this otherwise (and tbh, probably should, haha. It's been awhile since I seriously took a real look at my dotfiles!)

jacobwgillespie commented 3 years ago

I know this repo used to have a Brewfile for installing brew software - I'm using one in my dotfiles: https://github.com/jacobwgillespie/dotfiles/blob/main/Brewfile. You can install regular formulae, casks, fonts, even App Store apps.

brew bundle will install everything listed in the Brewfile, which is nice. I have a call to brew bundle in my setup script. In this repo, bin/dot does install Homebrew before executing the install.sh files, so you could add brew bundle to any install.sh or directly to dot.

Another cool thing that brew bundle can do is brew bundle cleanup. That will print all the things you have installed manually that are not in your Brewfile. And then brew bundle cleanup -f will actually uninstall those extra packages. In this way you can use a Brewfile as the source-of-truth for what's installed with Brew on your machine, and pretty easily find anything not covered and either add it or let Brew clean it up.

holman commented 3 years ago

Yeah, that's rad- I had a Brewfile before, but pulled it out for some reason that I can't quite remember. I think part of it might have been it didn't integrate as closely with the App Store (although it looks like that's more reasonable to do now). I also didn't know about bundle cleanup; that's really cool.