mkHomebrewFormula
mkHomebrewFormula generates a Homebrew formula (.rb) for packaging pre-built binary release archives. At Nix evaluation time, use the ":no_check" placeholder when the archives do not exist yet. After the release archives are built, use harbor-rs brew bump to compute real sha256 sums and update the tap.
The helper renders OS and CPU-specific downloads as nested Homebrew platform blocks, such as on_macos do with on_arm do or on_intel do inside it. A sha256 value of ":no_check" is emitted as Homebrew’s sha256 :no_check symbol for workflows that fill checksums later.
Parameters
pkgsname— Homebrew formula name, e.g.moddeversion— release version without a leadingvdescription— one-line description, 80 characters or fewerhomepage— HTTPS project URLlicense— SPDX license identifierplatforms— attrset keyed bydarwin_arm,darwin_intel,linux_arm, orlinux_intel; each value is{ url; sha256; }dependencies— list of Homebrew formula dependenciesbinaries— list of binaries installed intobincaveats— optional post-install messagetestBlock— optional Ruby body fortest doextraRubyBody— optional raw Ruby appended to the formula body
Example
packages.homebrew-formula = (harbor-rs.lib.mkHomebrewFormula {
inherit pkgs;
name = "my-app";
version = "1.0.0";
description = "My example application";
homepage = "https://example.com/my-app";
license = "MIT";
platforms = {
darwin_arm = {
url = "https://example.com/releases/my-app-1.0.0-aarch64-darwin.tar.gz";
sha256 = ":no_check";
};
darwin_intel = {
url = "https://example.com/releases/my-app-1.0.0-x86_64-darwin.tar.gz";
sha256 = ":no_check";
};
};
dependencies = ["openssl@3"];
binaries = ["my-app"];
testBlock = ''system "#{bin}/my-app", "--version"'';
}).formulaPath;
The returned attrset also includes formulaText for inspection or for downstream tools that need to rewrite placeholders before publishing.