Add support for Homebrew packages#2839
Open
mikeland73 wants to merge 4 commits into
Open
Conversation
Introduces a new `homebrew:` package scheme so users can install Homebrew
formulae through devbox, e.g.:
devbox add homebrew:python@3.10
Implementation mirrors the existing `runx:` mechanism:
- New pkgtype.Homebrew client that shells out to the `brew` CLI to
install formulae, query versioned formulae, look up install prefixes,
and search.
- Package gains IsHomebrew()/HomebrewFormula() helpers; IsNix() now
excludes both runx and homebrew packages so they're kept out of the
generated flake and nix store install path.
- When adding a versioned formula, devbox checks whether the base formula
ships "versioned_formulae". If it doesn't, it warns that the package
does not support versioned formulae (installing it anyway, with the
caveat that installing a different version replaces the existing one).
- On environment compute, HomebrewPaths installs the formulae and creates
symlinks under .devbox/virtenv/homebrew/bin (similar to runx) which is
added to PATH.
- `devbox search homebrew:foo` dispatches to `brew search`.
- Lockfile resolution records the homebrew formula identifier and version.
https://claude.ai/code/session_01DE2BpiRpGFhZiCf8RTcPAE
If a homebrew: package is added or built and the `brew` CLI is not installed, devbox now offers to install Homebrew: - Interactive terminals get a Y/n confirmation prompt (defaults to yes). - Non-interactive sessions install automatically. Homebrew is installed via the official install script with NONINTERACTIVE=1, which works on both macOS and Linux. After installation devbox locates the `brew` binary in its default install locations (including /home/linuxbrew/.linuxbrew on Linux) and adds it to PATH for the current process, so it can be used immediately without restarting the shell. The brew client now resolves the `brew` binary from these known locations in addition to PATH, so devbox can drive it right after a fresh install. https://claude.ai/code/session_01DE2BpiRpGFhZiCf8RTcPAE
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds homebrew: package support so devbox can resolve, install, search, and expose Homebrew formula executables alongside existing Nix and RunX packages.
Changes:
- Adds a Homebrew package type/client that shells out to
brew, including bootstrap support. - Integrates Homebrew packages into add/install/env PATH flows and lockfile resolution.
- Adds Homebrew search and package classification tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
internal/lock/resolve.go |
Adds lockfile resolution for Homebrew package references. |
internal/lock/lockfile.go |
Includes Homebrew packages in lockfile resolution paths. |
internal/devpkg/pkgtype/homebrew.go |
Adds Homebrew package detection, install, info, prefix, bootstrap, and search client logic. |
internal/devpkg/pkgtype/homebrew_test.go |
Adds Homebrew package type detection tests. |
internal/devpkg/pkgtype/flake.go |
Excludes Homebrew references from flake detection. |
internal/devpkg/package.go |
Adds Homebrew classification, formula extraction, docs URL, and Nix filtering updates. |
internal/devpkg/package_test.go |
Adds Homebrew package behavior coverage. |
internal/devbox/packages.go |
Adds Homebrew handling to add/install flows and store-path filtering. |
internal/devbox/devbox.go |
Adds Homebrew executable symlink directory to computed PATH. |
internal/boxcli/search.go |
Adds devbox search homebrew:<query> support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Reject empty `homebrew:` formula at add time with a clear message instead of failing later in `brew --prefix ""`. - Validate that a requested versioned formula (e.g. python@3.10) is actually one of the formula's versioned variants, rejecting bogus versions during add rather than at install time. - Treat the synthetic `@latest` suffix as unversioned in homebrew lock resolution so unversioned homebrew packages don't appear perpetually outdated. - Split `brew search` output on whitespace so column-formatted results return individual formulae. - Fix golangci-lint varnamelen findings (rename hb -> client, f -> tmpFile). https://claude.ai/code/session_01DE2BpiRpGFhZiCf8RTcPAE
Rename the table-test loop variable from tt to test; its usage spans more than golangci-lint's max-distance, which tripped varnamelen. https://claude.ai/code/session_01DE2BpiRpGFhZiCf8RTcPAE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for installing packages via Homebrew, enabling users to specify packages with the
homebrew:prefix (e.g.,homebrew:python@3.10). The implementation includes:Homebrewclient inpkgtypethat shells out to thebrewCLI to install and inspect formulaedevbox searchcommandKey features:
brew installrather than through NixHow was it tested?
IsHomebrew()function and Homebrew package detectionHomebrewPackagecovering formula extraction and package type detectionCommunity Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.
https://claude.ai/code/session_01DE2BpiRpGFhZiCf8RTcPAE