This repository packages OpenCode (terminal-based AI assistant) as a Nix flake, downloading pre-built binaries from npm registry and creating proper Nix store structure with platform-specific support.
nix build- Build the OpenCode packagenix flake check- Run all flake checks (includes package build, version, binary, and library structure tests)nix run . -- --version- Test the built OpenCode binary versionnix develop- Enter development shell with OpenCode available./scripts/test-workflow.sh- Test the complete update workflow locally
When updating OpenCode version:
- Update
opencodeVersionvariable in flake.nix (currently 0.1.157) - this is the single source of truth - Update all hashes in
packageHashesusingnix-prefetch-urlfor each platform package - Convert hashes to SRI format with
nix hash to-sri sha256:{hash} - Version checks automatically use the same
opencodeVersionvariable - no manual sync needed
- Language: Nix expressions with functional programming style
- Formatting: 2-space indentation, align attributes vertically
- Naming: Use camelCase for variables, kebab-case for package names
- Comments: Use
#for single-line comments, document complex logic - Imports: Use
let...inblocks for local bindings, inherit from inputs explicitly - Error Handling: Use
throwfor unsupported systems, validate hashes exist - Version Management: Update both
versionin flake.nix andpackageHasheswhen upgrading - Platform Support: Maintain compatibility across aarch64/x86_64 for darwin/linux
- Dependencies: Use
nativeBuildInputsfor build-time deps,buildInputsfor runtime - File Structure: Keep package definition in
package.nix, main flake config inflake.nix
- All changes must pass
nix flake checkbefore commit - Version mismatches between flake.nix (line 37) and expected version (line 47) indicate update needed
- Use
scripts/test-workflow.shto simulate version updates locally