You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Installed OpenCode via 'npm install -g --prefix "$HOME/.local" opencode-ai@latest'.
Ran it and got this:
bash> opencode
Could not start dynamically linked executable: opencode
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
There is an "opencode" on nixpkgs but it is an extremely old version at this point.
Making assumptions about what's available on a linux install at runtime just because you're running on "a linux" is bad design. Neither codex nor gemini nor claude (all of which I have installed identically to the method above; they're available on nixpkgs, but the above method keeps them always at the bleeding edge) make this assumption and all run just fine.
Even better, perhaps someone should update the version on nixpkgs on a more regular basis, but none of the others do that either, so that's probably a big ask. ;)
changed the title [-]Unable to even run opencode on NixOS because it makes unfortunate assumptions about linux distros[/-][+]make opencode work w/ NixOS[/+]on Oct 29, 2025
@xamcost While I'm not yet on the home-manager train (long story: short time and LOTS of dotfiles), I do like how the declarative config for it is stored that way too, there.
This is also broken. Home-manager only provides an overlay for configs, but still uses the original opencode nixpkgs package. That one currently only displays Bun is a fast JavaScript runtime, package manager, bundler, and test runner. when you run it and the previous working version you could pin is far before 1.0.
I think the best way forward would be to have a flake natively provided by the opencode team. This is how most fast moving projects do it to avoid having old versions in nixpkgs and to have the best experience for the users. You would also have full control over the build pipeline and dependencies, as the flake.nix would live here at the root of the repo.
A good example for this would be walker (https://github.com/abenz1267/walker) or the hyprland landscape.
Are there any plans to support Nix in the future @thdxr ?
Reacted by Oliver Geneser, MartinFides, Adam Delo, Peter Marreck, Luo Chen and Mateus Pereira
@itpropro I think what you are saying makes total sense, the issue we have had thus far is none of us use nix. That's partially why the "help-wanted" tag is on this issue because we are hoping someone in the community can help get this started and we will give them what they need to do so.
Keeping it first party supported makes sense
Reacted by Jan-Henrik Damaschke, TAnderson, MartinFides, Thomas King, Adam Delo and Mateus Pereira
I was hitting hash mismatches with the upstream flake and the stub-ld error on runtime. I got it working w/ a local overlay that pins the version, and uses autoPatchelfHook, and nix-ld.
Here is the working configuration for anyone stuck:
You have to enable nix-ld in your configuration.nix: This fixes the stub-ld error by allowing dynamic binaries to run.
programs.nix-ld.enable = true;
Then create a local overlay that bypasses the hash mismatch issues
by pinning
final: prev:
let
version = "1.0.85";
# Hash for the source tarball
srcHash = "sha256-mUGFERzY7dbN2CwWWUhONvvwhlY0LrTAGZ168m8y0RE=";
# Hash for the node_modules (you will need to update this on releases)
nodeModulesHash = "sha256-xqiDrKpODha+cfU6UpXLEUcApZ1xEkjRpqzFVJmq1uA=";
src = prev.fetchFromGitHub {
owner = "sst";
repo = "opencode";
rev = "v${version}";
hash = srcHash;
};
mkNodeModules = prev.callPackage ./node-modules.nix {
hash = nodeModulesHash;
};
mkPackage = prev.callPackage ./opencode.nix { };
in
{
opencode = mkPackage {
inherit version src;
scripts = ./.;
target = "bun-linux-arm64";
modelsDev = ./models-api.json;
mkNodeModules = mkNodeModules;
};
}
3. opencode.nix (using autoPatchelfHook):
{ lib, stdenv, bun, makeWrapper, autoPatchelfHook, ... }:
args:
stdenv.mkDerivation (finalAttrs: {
pname = "opencode";
version = args.version;
src = args.src;
nativeBuildInputs = [
bun
makeWrapper
autoPatchelfHook
];
})
This setup builds v1.0.85 successfully and runs without crashing as of now, your target will be different bc I run nixos-asahi-linux (mac m1 ARM).
Reacted by Peter Marreck, Fedor Telnov and Jan-Henrik Damaschke
Activity
github-actions commentedon Oct 29, 2025
This issue might be a duplicate of existing issues. Please check:
unzipis present #3501: Related installation issue where OpenCode makes assumptions about available Linux toolsFeel free to ignore if none of these address your specific case.
[-]Unable to even run opencode on NixOS because it makes unfortunate assumptions about linux distros[/-][+]make opencode work w/ NixOS[/+]rekram1-node commentedon Oct 29, 2025
yeah we should fix this
xamcost commentedon Oct 29, 2025
I know it doesn't answer @pmarreck 's original question, but an opencode service is available in home-manager. I use this config, and it works like a charm:
Just dropping this in case that helps.
pmarreck commentedon Oct 31, 2025
@xamcost While I'm not yet on the home-manager train (long story: short time and LOTS of dotfiles), I do like how the declarative config for it is stored that way too, there.
itpropro commentedon Nov 4, 2025
This is also broken. Home-manager only provides an overlay for configs, but still uses the original opencode nixpkgs package. That one currently only displays
Bun is a fast JavaScript runtime, package manager, bundler, and test runner.when you run it and the previous working version you could pin is far before 1.0.itpropro commentedon Nov 4, 2025
I think the best way forward would be to have a flake natively provided by the opencode team. This is how most fast moving projects do it to avoid having old versions in nixpkgs and to have the best experience for the users. You would also have full control over the build pipeline and dependencies, as the flake.nix would live here at the root of the repo.
A good example for this would be walker (https://github.com/abenz1267/walker) or the hyprland landscape.
Are there any plans to support Nix in the future @thdxr ?
rekram1-node commentedon Nov 4, 2025
@itpropro I think what you are saying makes total sense, the issue we have had thus far is none of us use nix. That's partially why the "help-wanted" tag is on this issue because we are hoping someone in the community can help get this started and we will give them what they need to do so.
Keeping it first party supported makes sense
rekram1-node commentedon Nov 18, 2025
Okay I think this may be good now?
nix run nixpkgs#opencode # or github:sst/opencode for latest dev branch
parkers0405 commentedon Nov 21, 2025
I was hitting hash mismatches with the upstream flake and the stub-ld error on runtime. I got it working w/ a local overlay that pins the version, and uses autoPatchelfHook, and nix-ld.
Here is the working configuration for anyone stuck:
by pinning
This setup builds v1.0.85 successfully and runs without crashing as of now, your target will be different bc I run nixos-asahi-linux (mac m1 ARM).
azuline commentedon Jan 2, 2026
#3924 this works for me, should the issue be closed? i came here and thought there was no support until i found a flake.nix in the root
itpropro commentedon Jan 2, 2026
This can be closed, the flake works fine, thanks for adding it!