Core API
Write files, create symlinks, run commands, and manage packages from your Lua config.
For system information, see rb.host. For secrets from 1Password, see Secrets. For per-machine configuration, see Profiles. For managed packages and lockfile modes, see Packages.
local rb = require("rootbeer")rb.profile
The first-class profile system. See the Profiles guide for the complete walkthrough. The module exposes:
rb.profile.define({ strategy, profiles })— declare profiles + the resolution strategy in one call.rb.profile.current()— the active profile name (ornil).rb.profile.select(map)/when(names, fn)/config(map)— branch on the active profile.- Custom strategy functions receive
ctx.match(value),ctx.cli(),ctx.hostname(), andctx.user()for explicit strategy composition.
Package declarations
rb.packages({ "ripgrep", "jq" }) declares a package list. rb.package("ripgrep") accepts one entry. Add @version to choose an exact version. Rootbeer saves package versions in rootbeer.lock.
Find packages or follow the package guide to get started.
API Reference
rootbeer.bin_dir()
Returns the configuration profile's stable binary directory without checking installation.
Returns
string — path — Configuration profile binary directory.rootbeer.bin_path(bin)
Returns a command's stable path in the configuration profile without checking installation. Declare the package before using this path in a deferred exec() call.
Parameters
binstringReturns
string — path — Configuration profile command path.rootbeer.copy_file(src, dst)
Copies a file from the script directory to the destination, but only if the destination does not already exist. Useful for seeding configuration files that the user (or an application) is expected to modify after the initial bootstrap (e.g. an editor config that records UI state). The source path is relative to the script directory and must exist. The destination supports ~ expansion. If the destination already exists, the operation is reported as skip.
Parameters
srcstringdststring~ expansion).rootbeer.env_export(shell)
Writes a shell environment file and returns its path. Source this file from your shell configuration to use installed commands.
shell:
| "sh"
| "bash"
| "zsh"Parameters
shell"bash"|"sh"|"zsh"optional"sh".Returns
stringrootbeer.exec(cmd, args)
Executes a command in the source directory. The command is deferred until the apply stage.
Parameters
cmdstring"brew").argsstring[]optionalrootbeer.file(path, content)
Writes content to a file. Parent directories are created automatically. Paths starting with ~ are expanded to $HOME; relative paths resolve from the script directory.
Parameters
pathstringcontentstringrootbeer.is_dir(path)
Checks whether a path is a directory. Supports ~ expansion and relative paths.
Parameters
pathstringReturns
booleanrootbeer.is_file(path)
Checks whether a path is a regular file. Supports ~ expansion and relative paths.
Parameters
pathstringReturns
booleanrootbeer.link(src, dst)
Creates a symbolic link between arbitrary paths. Both paths support ~ expansion and relative path resolution. Unlike link_file, the source is not restricted to the script directory. The source must exist at plan time.
Parameters
srcstring~ expansion).dststring~ expansion).rootbeer.link_file(src, dst)
Creates a symbolic link from a file in the script directory. The source path is relative to the script directory and must exist. The destination supports ~ expansion. Idempotent — existing correct links are skipped, stale links are replaced.
Parameters
srcstringdststring~ expansion).rootbeer.package(spec, opts)
Installs a command-line tool, such as "ripgrep". Use "name@version" to choose an exact version. Package versions are saved in rootbeer.lock. You can also use github:owner/repo@tag for a GitHub release's asset.
Parameters
specstring|rootbeer.PackageRequestSpecgithub: requests.rootbeer.package_catalog(path)
Builds packages from a checkout of recipes, laid out like the package index with packages/<name>.lua and host.lua. A name the checkout defines comes from its recipe instead of the index, and everything else still comes from the index. A build the index publishes under the same key is downloaded, and the rest builds on this machine.
Parameters
pathstringrootbeer.packages(specs)
Declares a dense package list in order. Accepts the same entries as package(). Validates every entry before adding operations; errors identify the invalid index.
Parameters
specs(string|rootbeer.PackageRequestSpec)[]rootbeer.path_exists(path)
Checks whether a path exists (file, directory, or symlink). Supports ~ expansion and relative paths.
Parameters
pathstringReturns
booleanrootbeer.read_file(path)
Reads a UTF-8 file during planning. Relative paths resolve from the source directory; paths starting with ~ expand to the home directory.
Parameters
pathstringReturns
string — content — File contents, including whitespace.rootbeer.remote(url)
Sets the origin remote URL for the rootbeer source directory. The change is deferred until the apply stage. Idempotent — skipped when the current URL already matches.
Parameters
urlstringrootbeer.which(bin)
Returns the stable Rootbeer profile path for a managed binary, or nil when the binary is not provided by the current plan/profile. This never searches the host PATH.
Parameters
binstringReturns
stringrootbeer.PackageOptions
assetstringoptionalbinstable<string, string>optionalrootbeer.PackageRequestSpec
assetstringoptionalbinstable<string, string>optionalrequeststring