Skip to content

Add support for Homebrew packages#2839

Open
mikeland73 wants to merge 4 commits into
mainfrom
claude/ecstatic-dijkstra-gt2Q5
Open

Add support for Homebrew packages#2839
mikeland73 wants to merge 4 commits into
mainfrom
claude/ecstatic-dijkstra-gt2Q5

Conversation

@mikeland73
Copy link
Copy Markdown
Collaborator

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:

  • New Homebrew client in pkgtype that shells out to the brew CLI to install and inspect formulae
  • Automatic Homebrew installation via the official installer script if not already present
  • Integration with devbox's package management to handle Homebrew packages alongside Nix and RunX packages
  • Support for versioned Homebrew formulae with validation and user warnings
  • Homebrew package search functionality via the devbox search command
  • Symlink-based PATH management for Homebrew executables, mirroring the RunX approach

Key features:

  • Homebrew packages are installed directly via brew install rather than through Nix
  • The system checks multiple known Homebrew installation paths and updates PATH after installation
  • When a versioned formula is requested but the base formula doesn't support versioning, the user is warned and the unversioned formula is used
  • Homebrew installation is prompted interactively when needed, or automatic in non-interactive environments
  • Works on both macOS and Linux

How was it tested?

  • Added unit tests for IsHomebrew() function and Homebrew package detection
  • Added test cases for HomebrewPackage covering formula extraction and package type detection
  • Existing test suite passes with new package type handling integrated into the filter logic
  • The implementation properly distinguishes between Nix, RunX, and Homebrew packages in package resolution and installation flows

Community 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

claude added 2 commits May 31, 2026 17:55
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
Copilot AI review requested due to automatic review settings May 31, 2026 18:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread internal/lock/resolve.go
Comment thread internal/devbox/packages.go Outdated
Comment thread internal/devbox/packages.go
Comment thread internal/devpkg/pkgtype/homebrew.go
claude added 2 commits May 31, 2026 18:27
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants