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: use mas from Nixpkgs #1329

Merged
merged 1 commit into from
Feb 10, 2025
Merged

Conversation

emilazy
Copy link
Collaborator

@emilazy emilazy commented 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: #1314


This should probably wait until NixOS/nixpkgs#379858 is merged since the Nixpkgs mas package is quite old right now (although it’s been working fine for me). I’ll take a look at that PR in the next couple days if nobody else gets around to it.

cc @sellout

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
@emilazy emilazy requested a review from Enzime February 8, 2025 16:24
Copy link
Contributor

@sellout sellout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks.

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.

This did work for me, but I initially thought it wouldn’t because I pull my configuration together from multiple repos, and I had packages in homebrew.brews (because they weren’t in Nixpkgs, or weren’t working on darwin via Nixpkgs). But it turned out that there was only one for that particular host, and it had since been fixed in Nixpkgs, so I removed it.

tl;dr – it’s not always fine to mkForce [] the list (and I wish there were better ways for manipulating lists, rather than just replacing them).

This should probably wait until NixOS/nixpkgs#379858 is merged since the Nixpkgs mas package is quite old right now (although it’s been working fine for me).

I have had some issues with Nixpkgs current mas when using uninstall, which is annoying as I have an activation script that uninstalls App Store packages that aren’t included in my nix-darwin configuration.

@@ -789,7 +785,8 @@ in
# Homebrew Bundle
echo >&2 "Homebrew bundle..."
if [ -f "${cfg.brewPrefix}/brew" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think this is very likely, but what if brew is not in brewPrefix1? Then mas won’t be added to the PATH.

Footnotes

  1. If brew isn’t on the PATH, then there are bigger issues, but it could just be in a non-standard location, but still on the PATH.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else condition is just an error message, so that seems okay?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops – I overlooked that. Yeah, totally fine, sorry.

@emilazy emilazy merged commit a36049d into LnL7:master Feb 10, 2025
3 checks passed
@emilazy emilazy deleted the push-nlxwnqymuupk branch February 10, 2025 23:20
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 this pull request may close these issues.

homebrew: add masPackage option
3 participants