Always up-to-date Nix package for the latest stable OpenCode CLI release from GitHub Releases.
Automatically updated hourly to keep this flake close to the latest stable OpenCode release.
This repository follows the packaging approach from jaylabit/github-copilot-nix by @jaylabit.
That project is based on the packaging approach from sadjow/claude-code-nix by @sadjow.
Related Nix package flakes from the same ecosystem:
OpenCode already has several installation paths, including npm, Homebrew, Arch packages, nixpkgs, and the upstream repository flake. This flake exists for one narrow use case:
- Stable Release Artifacts: Packages OpenCode's official GitHub release archives, not the upstream development branch.
- Immediate Updates: New stable OpenCode releases are checked hourly.
- Flake-First Design: Direct usage from NixOS, Home Manager,
nix profile, andnix run. - Native Binary Packaging: Uses upstream native Linux and macOS CLI archives.
- Reproducible Pinning: Version and per-platform fixed-output hashes are recorded in
sources.json.
OpenCode documents:
nix run nixpkgs#opencode # or github:anomalyco/opencode for latest dev branchgithub:anomalyco/opencode is useful when you intentionally want the latest development branch. This repository instead tracks the latest stable GitHub release and pins the exact downloaded artifacts.
OpenCode's installer works well for imperative systems:
curl -fsSL https://opencode.ai/install | bashFor Nix users, installer-managed software has the usual limitations:
- Not Declarative: It is not managed by your NixOS or Home Manager configuration.
- Harder to Pin: Exact version pinning and rollback are manual.
- Outside Nix: The installed binary is not part of the Nix store.
- Less Reproducible: Installation depends on mutable external state at install time.
This flake keeps OpenCode in the Nix store with fixed-output hashes while still using OpenCode's official release artifacts.
If opencode is available and current in your nixpkgs revision, it is often the best default for broad community review. A dedicated flake is useful when you want a faster update cadence for stable releases:
- nixpkgs pull requests can take time to review and merge.
- updates depend on maintainer availability.
- you are tied to your nixpkgs channel's update schedule.
- urgent packaging changes can be delayed.
This repository provides:
- Hourly Automated Checks: GitHub Actions checks for new upstream stable releases.
- Pinned Release Artifacts:
package.nixfetches GitHub release archives with fixed hashes. - Multi-Platform Support: Linux and macOS, x86_64 and aarch64.
- Simple Update Script:
scripts/update-version.shprefetches release assets with Nix and updatessources.json. - Version Tags: New packaged releases create
vX.Y.Z,vX, andlatesttags.
| Feature | Official installer | nixpkgs / upstream flake | This flake |
|---|---|---|---|
| Latest Stable Version | Usually latest | Can lag or track dev branch | Hourly checks |
| Declarative Config | No | Yes | Yes |
| Nix Store Package | No | Yes | Yes |
| Version Pinning | Manual | By nixpkgs or flake lock | Exact tags or commit SHAs |
| Rollback | Manual | Nix profile/system rollback | Nix profile/system rollback |
| Reproducible Fetches | No | Yes | Yes |
| Update Frequency | Immediate | Channel-dependent | Automated hourly check |
| Broad Review | OpenCode only | nixpkgs / upstream review | This repository |
nix run github:kubajanusz/opencode-nixnix profile install github:kubajanusz/opencode-nixwhich opencode
opencode --versionIf you are not using NixOS or Home Manager, use nix profile.
nix profile install github:kubajanusz/opencode-nix# Update all flake-based profile packages
nix profile upgrade --all
# Or update only OpenCode
nix profile upgrade '.*opencode.*'nix profile rollbacknix profile remove '.*opencode.*'If opencode is not found after installation, ensure ~/.nix-profile/bin is in your PATH:
echo "$PATH" | tr ':' '\n' | grep nix-profileIf it is missing, add this to your shell configuration:
export PATH="$HOME/.nix-profile/bin:$PATH"For multi-user Nix installations, this is typically configured through /etc/profile.d/nix.sh or equivalent shell integration.
{
nixpkgs.overlays = [ opencode-nix.overlays.default ];
# pkgs.opencode is now available
}{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
opencode-nix.url = "github:kubajanusz/opencode-nix";
};
outputs = { nixpkgs, opencode-nix, ... }: {
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ pkgs, ... }: {
nixpkgs.overlays = [ opencode-nix.overlays.default ];
environment.systemPackages = [ pkgs.opencode ];
})
];
};
};
}{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
opencode-nix.url = "github:kubajanusz/opencode-nix";
};
outputs = { nixpkgs, home-manager, opencode-nix, ... }: {
homeConfigurations."username" =
let
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [ opencode-nix.overlays.default ];
};
in
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
{
home.packages = [ pkgs.opencode ];
}
];
};
};
}{
inputs.opencode-nix.url = "github:kubajanusz/opencode-nix";
outputs = { opencode-nix, ... }: {
packages.x86_64-linux.my-opencode = opencode-nix.packages.x86_64-linux.default;
};
}Choose between immutable pins and moving update channels using git refs.
Only exact version tags such as v1.14.46 or exact commit SHAs are true pins. v1, latest, and the default branch are moving refs that intentionally follow newer commits over time.
| Ref | Example | Behavior | Security Posture |
|---|---|---|---|
| Exact version tag | v1.14.46 |
Immutable release tag | Best default for reproducible installs |
| Major tag | v1 |
Latest release in that major line | Moving channel, updates over time |
latest tag |
latest |
Newest packaged release | Moving channel, updates over time |
| Default branch | github:kubajanusz/opencode-nix |
Tracks repository main |
Moving channel, fastest updates |
# Always latest from the default branch
nix run github:kubajanusz/opencode-nix
# Pin to an exact immutable release
nix run github:kubajanusz/opencode-nix?ref=v1.14.46
# Track latest v1.x
nix run github:kubajanusz/opencode-nix?ref=v1
# Track the moving latest tag
nix run github:kubajanusz/opencode-nix?ref=latest{
inputs = {
# Always latest from the default branch
opencode-nix.url = "github:kubajanusz/opencode-nix";
# Pin to an exact immutable release
opencode-nix.url = "github:kubajanusz/opencode-nix?ref=v1.14.46";
# Track major version
opencode-nix.url = "github:kubajanusz/opencode-nix?ref=v1";
};
}If you use this repository as a flake input, your own flake.lock records the resolved commit. Exact tags and commit SHAs give the strongest control; moving refs such as main, v1, and latest only change when you update your lock file.
This repository is optimized for fast stable OpenCode updates. That makes the trust model worth stating explicitly.
package.nixfetches native release archives with fixed hashes.sources.jsonrecords the expected version and per-platform hashes.flake.lockpins flake inputs for a given repository revision.- CI builds and smoke-tests the package before update PRs land on
main. - The updater prefetches assets from the matching upstream GitHub release with Nix.
- Trusting this repo means trusting the maintainer account and the GitHub Actions workflow that creates update PRs.
- The upstream artifacts come from the
anomalyco/opencoderelease page. - Moving refs such as
main,v1, andlatesttrade stricter change control for convenience and freshness.
| Goal | Recommended Setup |
|---|---|
| Highest assurance | Pin an exact commit SHA and review updates manually |
| Balanced default | Pin an exact version tag |
| Fastest updates | Track the default branch, v1, or latest |
Forking is a valid option if you want to fully control update cadence, review upstream diffs yourself, or add additional policy checks before merging updates.
For most users, pinning an exact version tag is simpler and usually enough. A fork only meaningfully improves security if you also add your own review gate instead of automatically tracking upstream.
If you prefer a slower update cadence with broader community review, upstream nixpkgs may be a better fit than this flake.
- Downloads pre-built native binaries from OpenCode GitHub releases.
- Uses the stable CLI release assets:
opencode-linux-x64.tar.gzopencode-linux-arm64.tar.gzopencode-darwin-x64.zipopencode-darwin-arm64.zip
- Uses
autoPatchelfHookon Linux for NixOS compatibility. - Installs the
opencodebinary into$out/bin/opencode. - Keeps release version and hashes in
sources.json.
x86_64-linuxaarch64-linuxx86_64-darwinaarch64-darwin
# Clone the repository
git clone https://github.com/kubajanusz/opencode-nix
cd opencode-nix
# Enter development shell
nix develop
# Build the package
nix build
# Run a smoke test
./result/bin/opencode --version
# Check for version updates
./scripts/update-version.sh --checkThis repository uses GitHub Actions to check for new OpenCode versions every hour. When a new version is detected:
- A pull request is automatically created with the version update.
sources.jsonis updated with the new version and hashes for all supported platforms.flake.lockis updated.- CI runs on Ubuntu and macOS.
- Version tags are created only for newly packaged releases (
vX.Y.Z,vX,latest).
The automated update workflow runs:
- every hour
- on manual trigger via the GitHub Actions UI
This workflow is designed for freshness and build validation, not for manual review of every upstream release.
Automated update PRs require repository settings that allow GitHub Actions to write contents and create pull requests. See .github/REPOSITORY_SETTINGS.md or run:
./scripts/setup-github-permissions.sh# Check for updates
./scripts/update-version.sh --check
# Update to latest version
./scripts/update-version.sh
# Update to a specific version
./scripts/update-version.sh --version 1.14.46
# Print latest upstream version
./scripts/update-version.sh --latest-version
# Show help
./scripts/update-version.sh --helpThe script automatically:
- fetches the latest upstream release version
- prefetches supported release assets with Nix
- updates
sources.json - updates
flake.lock - verifies that the package builds
If you prefer to update manually:
- Edit
sources.jsonand change theversionfield. - Prefetch each relevant release asset with
nix store prefetch-file --hash-type sha256 --json URL. - Update the matching hash entries in
sources.json. - Run
nix flake update. - Build and test locally:
nix build && ./result/bin/opencode --version. - Submit a pull request.
OpenCode may report that a newer version is available. With this flake, updates should happen through Nix:
nix profile upgrade '.*opencode.*'or by updating your flake lock:
nix flake update opencode-nixCheck whether the Nix profile path is available:
echo "$PATH" | tr ':' '\n' | grep nix-profileIf you installed through NixOS or Home Manager, rebuild or switch your configuration and open a new shell.
curl -fsSL https://opencode.ai/install | bashnpm i -g opencode-ai@latest
brew install anomalyco/tap/opencode
nix run nixpkgs#opencode
nix run github:anomalyco/opencode| Aspect | Official native install | This Nix flake |
|---|---|---|
| Simplicity | One command | Requires Nix |
| Official binary | Yes | Yes |
| Stable releases | Yes | Yes |
| Latest stable version | Usually latest | Hourly checks |
| Version pinning | Manual | Git tags / commit SHAs |
| Rollback | Manual | Nix profile/system rollback |
| Declarative | No | NixOS/Home Manager |
| Windows | Native installer available | Use via WSL or unsupported directly |
Choose the official installer if you want the simplest setup or do not use Nix.
Choose this flake if you use NixOS or Home Manager, want declarative configuration, and are comfortable choosing between exact pins and faster-moving update channels.
The Nix packaging in this repository is MIT licensed. OpenCode itself is MIT licensed by the OpenCode project.