tundrabrew

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

tundra-brew

A typed model of a Homebrew Formula, rendered to a deterministic, byte-stable Ruby .rb string.

What

Build a Formula with functional options (URL, source + per-platform bottle SHA-256s, dependencies, install/test stanzas), Validate it, and Render it to the exact .rb Homebrew expects — instead of hand-editing a formula and pasting checksums by hand. It is a pure, generic Homebrew primitive: it models any formula and never names or imports a particular project.

Why

Any release pipeline that publishes to a Homebrew tap needs to emit a formula with the new version + freshly-computed bottle hashes. Doing that by hand is error-prone and duplicated per project. tundra-brew is the one shared model so a release action renders the formula from a typed manifest, byte-stable across runs.

Install

go get github.com/pleme-io/tundra-brew

Nix (via substrate):

outputs = { self, nixpkgs, substrate, ... }:
  (import substrate.goLibraryFlakeBuilder { inherit nixpkgs; }) {
    name = "tundra-brew"; version = "0.1.0"; src = self;
  };

Usage

Built on: errors-go (typed, code-carrying errors).

f := tundrabrew.New("widget",
    tundrabrew.WithDescription("A widget"),
    tundrabrew.WithHomepage("https://example.com"),
    tundrabrew.WithURL("https://example.com/widget-1.2.3.tar.gz"),
    tundrabrew.WithSHA256(srcHash),
    tundrabrew.WithVersion("1.2.3"),
    tundrabrew.WithLicense("MIT"),
    tundrabrew.WithBottle(tundrabrew.PlatformArm64Sonoma, armHash),
    tundrabrew.WithBottle(tundrabrew.PlatformX8664Linux, linuxHash),
    tundrabrew.WithInstall(`bin.install "widget"`),
    tundrabrew.WithTest(`system "#{bin}/widget", "--version"`),
)
rb, err := f.Render() // validated, byte-stable .rb
if err != nil {
    return errs.Exit(err)
}

Configuration

None — it is a pure library. Consumers that load the release manifest / tap location from a configured source use shikumi-go for that config and pass the typed values to New.

Release

Pull-model (Go modules): an annotated vX.Y.Z tag is the release; proxy.golang.org + pkg.go.dev index it. See the GSDS module delivery FSM.

Documentation

Overview

Package tundrabrew is the fleet's one typed model of a Homebrew Formula — so no tool hand-edits a `.rb` with sha256 hashes pasted by hand. A Formula is built with functional options, validated, and rendered to a deterministic, byte-stable Ruby `.rb` string.

It is a pure, generic Homebrew primitive: it models any formula (name, URL, per-platform bottle hashes, dependencies, install/test stanzas) and never names or imports any particular project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bottle

type Bottle struct {
	Platform Platform
	SHA256   string
}

Bottle is a precomputed binary package for one Platform, keyed by its SHA-256.

type Dependency

type Dependency struct {
	Name string
	Type string // "", "build", "test", "optional", "recommended"
}

Dependency is a formula dependency, optionally scoped (e.g. ":build", ":test").

type Formula

type Formula struct {
	// Name is the formula's Ruby class basename (e.g. "akeyless"); it is
	// title-cased into the class declaration automatically.
	Name        string
	Description string
	Homepage    string
	// URL is the source tarball / release archive URL.
	URL string
	// SHA256 is the source archive checksum (distinct from per-platform bottles).
	SHA256  string
	Version string
	License string

	Bottles      []Bottle
	Dependencies []Dependency

	// InstallLines are the Ruby statements inside the `def install` block.
	InstallLines []string
	// TestLines are the Ruby statements inside the `test do` block.
	TestLines []string
}

Formula is a typed, options-built Homebrew formula. The zero value is invalid; build it through New.

func New

func New(name string, opts ...Option) *Formula

New builds a Formula from a required name and options. It does not validate; call Validate (or Render, which validates first).

func (*Formula) ClassName

func (f *Formula) ClassName() string

ClassName returns the Ruby class name Homebrew expects (CamelCase of the formula name, with "-" and "_" treated as word separators). E.g. "my-tool" → "MyTool".

func (*Formula) Render

func (f *Formula) Render() (string, error)

Render validates the formula and produces a deterministic, byte-stable Ruby `.rb` string. Bottles are sorted by platform so the output never reorders between runs.

func (*Formula) Validate

func (f *Formula) Validate() error

Validate reports the first structural problem with the formula as a typed, code-carrying error. A valid formula has a name, a URL, and a source SHA-256.

type Option

type Option func(*Formula)

Option configures a Formula.

func WithBottle

func WithBottle(p Platform, sha256 string) Option

WithBottle appends a per-platform bottle (a Platform + its SHA-256).

func WithDependency

func WithDependency(name, typ string) Option

WithDependency appends a dependency. typ may be "" for a plain runtime dep.

func WithDescription

func WithDescription(d string) Option

WithDescription sets the formula description (`desc`).

func WithHomepage

func WithHomepage(h string) Option

WithHomepage sets the homepage URL.

func WithInstall

func WithInstall(lines ...string) Option

WithInstall sets the lines of the `def install` block.

func WithLicense

func WithLicense(l string) Option

WithLicense sets the SPDX license identifier.

func WithSHA256

func WithSHA256(s string) Option

WithSHA256 sets the source archive checksum.

func WithTest

func WithTest(lines ...string) Option

WithTest sets the lines of the `test do` block.

func WithURL

func WithURL(u string) Option

WithURL sets the source archive URL.

func WithVersion

func WithVersion(v string) Option

WithVersion sets the formula version.

type Platform

type Platform string

Platform identifies a Homebrew bottle target (an OS/arch tag). The string is emitted verbatim into the bottle DSL, e.g. "arm64_sonoma", "x86_64_linux".

const (
	PlatformArm64Sonoma Platform = "arm64_sonoma"
	PlatformVentura     Platform = "ventura"
	PlatformX8664Linux  Platform = "x86_64_linux"
)

Common bottle platforms. Consumers may use any string; these are conveniences.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址