Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homebrew: add masPackage option #1314

Closed
sellout opened this issue Jan 30, 2025 · 2 comments · Fixed by #1329
Closed

homebrew: add masPackage option #1314

sellout opened this issue Jan 30, 2025 · 2 comments · Fixed by #1329

Comments

@sellout
Copy link
Contributor

sellout commented Jan 30, 2025

When homebrew.masApps isn’t empty, the homebrew module adds "mas" to homebrew.brews.

Unfortunately, the mas formula is failing for me on an old Mac (stuck on Big Sur / macOS 11). But I can install pkgs.mas from Nixpkgs just fine, and brew will use that no problem.

The output is a bit funny. First Homebrew fails to install mas

Homebrew bundle...
Installing mas
Warning: You are using macOS 11.
We (and Apple) do not provide support for this old version.
It is expected behaviour that some formulae will fail to build in this old version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from Homebrew or its maintainers on social media.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.

mas: A full installation of Xcode.app 14.2 is required to compile
this software. Installing just the Command Line Tools is not sufficient.

Xcode 14.2 cannot be installed on macOS 11.
You must upgrade your version of macOS.
Error: mas: An unsatisfied requirement failed this build.
Installing mas has failed!

but then it later happily installs apps using mas.

Installing 1Password for Safari
Installing Deliveries
Installing Harvest
Installing reMarkable
Homebrew Bundle failed! 1 Brewfile dependency failed to install.

The most unfortunate bit is that this success-despite-failure isn’t enough to get nix-darwin activation to complete, so I need to do something to get the module to not install mas via brew.

I was thinking an option like homebrew.masPackage. If it’s set to a derivation, just add that to environment.systemPackages (or maybe scope it to brew?). Otherwise, do the current behavior. I lean toward the default value being pkgs.mas (I try to only use Homebrew if I can’t get the package otherwise), but I also understand if null (i.e., the current behavior) is preferred.

@emilazy
Copy link
Collaborator

emilazy commented Jan 30, 2025

I just ran into this while working on activation $PATHs, funnily enough.

Since we have pkgs.mas I’m tempted to say we should just add that to the $PATH we run Homebrew with and not bother automatically adding the mas formula. That’s the setup I’ve used for years now with no issues (you can just add mas to environment.systemPackages and set homebrew.brews = lib.mkForce [ ];). Unfortunately it seems like the package in Nixpkgs is outdated, so this might only give the best user experience if someone keeps on top of new versions…

FWIW, Nixpkgs itself is not going to be supporting macOS 11 for more than a few months longer; see #1312 (comment) for more details and what options you have. If you can use something like OCLP to run a supported OS version on your old Mac I’d highly recommend that, as Apple haven’t been releasing security patches for macOS 11 for almost a year and a half now. There’s no real guarantee that Homebrew will keep brew bundle working on those versions either, even if you don’t need to build any formulas.

@sellout
Copy link
Contributor Author

sellout commented Feb 6, 2025

Thanks, @emilazy.

I put up a PR to upgrade mas: NixOS/nixpkgs#379858. I’ll add one here to switch over to using that package. mas doesn’t get releases very frequently, but yeah, it was three years behind.

I wasn’t aware of OCLP. My initial attempt to get the old machine upgraded wasn’t successful, but I’ll have to dig into that later. Really appreciate you bringing it to my attention.

emilazy added a commit to emilazy/nix-darwin that referenced this issue Feb 8, 2025
Currently, setting `homebrew.masApps` causes `"mas"` to automatically
be added to `homebrew.brews`. Users who want to use Homebrew only
for managing App Store apps and casks, like me, can override this
by setting `homebrew.brews = lib.mkForce [ ];` and adding Nixpkgs’
`mas` to their `environment.systemPackages`.

When the activation script path no longer depends on the built
configuration’s `environment.systemPackages`, this will no longer
work. Since this was originally added before `mas` was packaged in
Nixpkgs and we now have a perfectly serviceable binary package,
we can add it to the `$PATH` when invoking Homebrew and skip the
automatic formula installation.

As the Homebrew `bin` directory still comes first, users who
specifically want the formula can restore the previous behaviour by
explicitly adding `"mas"` to `homebrew.brews`.

Closes: LnL7#1314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants