Guide for coding agents working in this repository.
opencode-nix is a small standalone flake that packages the official
anomalyco/opencode stable release archives for Linux and macOS.
The repository is intentionally narrow:
- expose
opencodeas a flake package, app, and overlay - pin the packaged upstream version and hashes in
sources.json - automate version bumps with
scripts/update-version.sh - build/test in GitHub Actions
- tag only packaged releases
flake.nix/flake.lock- flake entrypoint and locked inputspackage.nix- derivation for theopencodebinarysources.json- source of truth for packaged version and per-platform hashesscripts/update-version.sh- updatessources.json, refreshesflake.lock, verifies buildscripts/setup-github-permissions.sh- helper text for required GitHub settings.github/workflows/build.yml- CI build and smoke test.github/workflows/update-opencode.yml- scheduled/manual update PR workflow.github/workflows/create-version-tag.yml- creates exact and moving tags for new packaged releases.github/dependabot.yml- weekly GitHub Actions dependency updatesREADME.md- user-facing docs
flake.nixexposes:packages.defaultpackages.opencodeapps.defaultapps.opencodeoverlays.default
package.nixmust keepsources.jsonas the only version/hash source.- The installed program name is
opencode.
sources.jsonis the canonical place for:- packaged upstream version
- asset name per supported system
- fixed SRI hash per supported system
- Supported systems are currently:
x86_64-linuxaarch64-linuxx86_64-darwinaarch64-darwin
- Asset names follow upstream stable release naming:
opencode-linux-x64.tar.gzopencode-linux-arm64.tar.gzopencode-darwin-x64.zipopencode-darwin-arm64.zip
- Prefer
./scripts/update-version.shover manual edits when bumping versions. - The update script:
- discovers the latest upstream release
- prefetches stable release assets with Nix
- rewrites
sources.json - runs
nix flake update - verifies with
nix build .#opencodeand./result/bin/opencode --version
- Keep the script simple and shell-only; do not add extra tooling unless necessary.
build.ymlis the main CI surface and should keep building on Ubuntu and macOS.update-opencode.ymlshould only open a PR when the packaged version actually changes.create-version-tag.ymlshould:- create exact tag
vX.Y.Zfor new packaged versions - move
vXandlatestonly when a new exact version is created - leave moving tags untouched if the packaged version is unchanged
- create exact tag
- Do not add Cachix or other binary-cache assumptions unless explicitly requested.
- Update
README.mdwhen changing:- user installation flow
- flake outputs
- update automation
- tag semantics
- trust/security behavior
- Keep README examples valid for this repo; do not leave copied references to other projects.
- Prefer small changes in the existing files over adding new abstraction layers.
- Keep
sources.jsonmachine-editable and stable in shape. - Do not rename the
opencodeexecutable or change public flake outputs unless the user asks. - Do not rewrite workflow behavior around tagging/update cadence without also updating README docs.
- Do not manually retag
v1/latestfor dependency-only changes when the packaged OpenCode version is unchanged. - Do not introduce secrets into the repository; workflows rely on GitHub-provided tokens/settings.
Use the smallest relevant validation set for the change:
- docs only:
git diff --check
- shell/workflow/docs changes:
bash -n scripts/*.shgit diff --check
- package/update changes:
nix flake check --print-build-logsnix build .#opencode -o result --print-build-logs./result/bin/opencode --version
- updater changes:
./scripts/update-version.sh --latest-version./scripts/update-version.sh --check
Automated update PRs require repository settings that allow Actions to:
- use
GITHUB_TOKENwith read/write permissions - create pull requests
- use auto-merge if that workflow step is enabled
See .github/REPOSITORY_SETTINGS.md when working on update automation.