Run and install OpenCode on NixOS, Home Manager, nix-darwin, or any system with Nix.
OpenCode is an AI coding agent. It runs in your terminal (CLI) or as a desktop app.
The flake is updated automatically every day.
| Package | What it is | Command | Platforms |
|---|---|---|---|
opencode (default) |
Terminal app (CLI) | opencode |
Linux, macOS |
opencode-desktop |
Desktop app (Electron) | opencode-desktop |
Linux only |
Linux: x86_64 and aarch64. macOS: Intel and Apple Silicon.
You need Nix with flakes enabled.
nix run github:Hy4ri/opencode-flake # CLI
nix run github:Hy4ri/opencode-flake#opencode-desktop # desktop appThere are two ways to install. Pick one. They give the same result.
| Option | Use it when |
|---|---|
| A. Overlay | You want to write pkgs.opencode, like any other nixpkgs package. |
| B. Direct package | You do not want to use overlays. |
In your system flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
opencode.url = "github:Hy4ri/opencode-flake";
};
outputs = { nixpkgs, ... }@inputs: {
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; }; # lets your modules use `inputs`
modules = [ ./configuration.nix ];
};
};
}Already have a flake? Add only the
opencode.urlline, and make sureinputsreaches your modules (specialArgsfor NixOS and nix-darwin,extraSpecialArgsfor Home Manager).
In configuration.nix:
{ inputs, pkgs, ... }:
{
nixpkgs.overlays = [ inputs.opencode.overlays.default ];
environment.systemPackages = [
pkgs.opencode
pkgs.opencode-desktop # Linux only
];
}For Home Manager, keep the overlay line and use home.packages = [ pkgs.opencode ]; instead.
Want only one app in pkgs? Use overlays.opencode or overlays.opencode-desktop instead of overlays.default.
In configuration.nix:
{ inputs, pkgs, ... }:
let
opencode = inputs.opencode.packages.${pkgs.stdenv.hostPlatform.system};
in
{
environment.systemPackages = [
opencode.opencode
opencode.opencode-desktop # Linux only
];
}For Home Manager, put the same packages in home.packages.
sudo nixos-rebuild switch --flake .#myhostA GitHub Action checks for new OpenCode releases every day at 17:00 UTC, tests the build, and commits the new version. To get it, update your lock file:
nix flake update opencodenix develop # shell with the update tools
./update-version.sh # latest release
./update-version.sh 1.16.0 # a specific versionThe script downloads every platform archive, computes the hashes, and updates version.json, opencode.nix, and opencode-desktop.nix.
- Fork the repository.
- Enter the dev shell:
nix develop. - Make your changes.
- Check them:
nix flake checkandnix build .#opencode. - Open a pull request.
This flake packaging is provided under the MIT license. OpenCode itself has its own license terms. Refer to the OpenCode repository for details.
If this flake helps you, you can support my work on GitHub Sponsors or Ko-fi. A star on the repo also helps.