Skip to content

opencode desktop 2.2.0 does not build on nixos (flake) #59601

Open

Description

@machineonamission

Description

with flake.nix inputs

    opencode.url = "github:anomalyco/opencode/v2.2.0";
    opencode.inputs.nixpkgs.follows = "nixpkgs-unstable";

nix build fails:

[root@MelDesktop3:/home/melody/Projects/NIXOS]# nixos-rebuild build
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error: Cannot build '/nix/store/1xzsrr5xn4jg6h0kcp67c1idlg224gar-opencode-desktop-2.2.0+1097e26.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/xznlb50w9zkfm95qp3glv2sqr0494sms-opencode-desktop-2.2.0+1097e26
       Last 25 log lines:
       > node_modules/.bun/ghostty-web@github+anomalyco+ghostty-web+e91e38a/node_modules/ghostty-web/demo/showcase.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/nnm9gdr70ihc6zc9298mzz8jpcgaciql-bash-5.3p20/bin/bash"
       > node_modules/.bun/ghostty-web@github+anomalyco+ghostty-web+e91e38a/node_modules/ghostty-web/scripts/build-wasm.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/nnm9gdr70ihc6zc9298mzz8jpcgaciql-bash-5.3p20/bin/bash"
       > node_modules/.bun/[email protected]+6c6101fa9d9a1fb4/node_modules/oxlint/bin/oxlint: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/@[email protected]+759ce506b1ed1a42/node_modules/@protobuf-ts/plugin/bin/protoc-gen-dump: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/@[email protected]+759ce506b1ed1a42/node_modules/@protobuf-ts/plugin/bin/protoc-gen-ts: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/[email protected]/node_modules/oxlint-tsgolint/bin/tsgolint.js: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/[email protected]/node_modules/regjsparser/bin/parser: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/[email protected]/node_modules/marked/bin/marked.js: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/[email protected]/node_modules/commonmark/bin/commonmark: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > patching script interpreter paths in packages/ai/node_modules packages/app/node_modules packages/cli/node_modules packages/client/node_modules packages/codemode/node_modules packages/core/node_modules packages/desktop/node_modules packages/gui-plugins/node_modules packages/http-recorder/node_modules packages/httpapi-codegen/node_modules packages/latex/node_modules packages/merman/node_modules packages/patchmark/node_modules packages/plugin-browser/node_modules packages/plugin/node_modules packages/protocol/node_modules packages/schema/node_modules packages/script/node_modules packages/server/node_modules packages/session-ui/node_modules packages/simulation/node_modules packages/theme/node_modules packages/tui/node_modules packages/ui/node_modules packages/util/node_modules
       > $ bun run script/build.ts
       > Copied prod icons from ./icons/prod to resources/icons
       > Generated metainfo for prod at resources/ai.opencode.desktop.metainfo.xml
       > 20 | await $`bun ./script/copy-metainfo.ts ${channel}`
       > 21 |
       > 22 | const built = await exists(path.join(cli, getCurrentCli().package.replace("@opencode/", "")))
       > 23 |
       > 24 | if (channel === "prod" && !built)
       > 25 |   throw new Error(`Production desktop builds bundle the CLI from ${cli}; build it first`)
       >                  ^
       > error: Production desktop builds bundle the CLI from /build/source/packages/cli/dist; build it first
       >       at /build/source/packages/desktop/script/build.ts:25:13
       > 
       > Bun v1.4.2 (Linux x64)
       > error: script "build" exited with code 1
       For full logs, run:
         nix log /nix/store/1xzsrr5xn4jg6h0kcp67c1idlg224gar-opencode-desktop-2.2.0+1097e26.drv
error: Cannot build '/nix/store/mn53crrqjszq8g4iyhwqp8p6js7cfa7w-system-path.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/j1badjm62n5h4m8h538glk6ay48cr6xd-system-path
error: Cannot build '/nix/store/8a5ah7xmawijfsnbfw8ry1s3zajliya2-nixos-system-MelDesktop3-26.11.20261023.3ec6363.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/hzjign2vac4k3wyp4aajcvv56974a16z-nixos-system-MelDesktop3-26.11.20261023.3ec6363
Command 'nix --extra-experimental-features 'nix-command flakes' build --print-out-paths '/etc/nixos#nixosConfigurations."MelDesktop3".config.system.build.toplevel'' returned non-zero exit status 1.

Plugins

N/A

OpenCode version

2.2.0

Steps to reproduce

flake.nix

    opencode.url = "github:anomalyco/opencode/v2.2.0";
    opencode.inputs.nixpkgs.follows = "nixpkgs-unstable";

nix module

environment.systemPackages = [
    inputs.opencode.packages.${pkgs.stdenv.hostPlatform.system}.opencode
    inputs.opencode.packages.${pkgs.stdenv.hostPlatform.system}.opencode-desktop  
  ];

Screenshot

[root@MelDesktop3:/home/melody/Projects/NIXOS]# nixos-rebuild build --verbose --show-trace
debug: nixos_rebuild.process: calling run with args=['nix-instantiate', '--find-file', 'nixos-system'], kwargs={'capture_output': True}, env=None, append_local_env=None
debug: nixos_rebuild.process: captured output with stdout='', stderr="error: file 'nixos-system' was not found in the Nix search path (add it using $NIX_PATH or -I)\n"
building the system configuration...
debug: nixos_rebuild.process: calling run with args=['nix', '--extra-experimental-features', 'nix-command flakes', 'build', '--print-out-paths', '/etc/nixos#nixosConfigurations."MelDesktop3".config.system.build.toplevel', '-v', '--show-trace'], kwargs={'stdout': -1}, env=None, append_local_env=None
warning: Git tree '/etc/nixos' is dirty
these 14 derivations will be built:
  /nix/store/1xzsrr5xn4jg6h0kcp67c1idlg224gar-opencode-desktop-2.2.0+1097e26.drv
  /nix/store/mn53crrqjszq8g4iyhwqp8p6js7cfa7w-system-path.drv
  /nix/store/qychqx8144ll8sz9jdsc2hryqyiwp0ds-dbus-1.drv
  /nix/store/bg9byx8g824vz8zwl7bbvdx8xssh910v-X-Restart-Triggers-polkit.drv
  /nix/store/cdnb199fqam5xwiz4mdbzggwm4lrr513-unit-polkit.service.drv
  /nix/store/w0mnl96dmwpdg0dsqml5afzgpwksdy48-X-Restart-Triggers-dbus-broker.drv
  /nix/store/f4b4ij6br7q580mrj5ymdjax9h5gyyf2-unit-dbus-broker.service.drv
  /nix/store/q7w9gympf3nzwnqpzb4ls5dyw59acab2-unit-accounts-daemon.service.drv
  /nix/store/sh5kq3gkz4jkjd3rwh8p9h8fh5j01mj3-system-units.drv
  /nix/store/zs4g2yglsvwhpsd00k8mq5irhdh4d15b-unit-dbus-broker.service.drv
  /nix/store/x74r7cgqzij4lbsvdrx90650n1wa6cd4-user-units.drv
  /nix/store/pa4zwg5idv3d696a393m5ifgxxg6i7dv-etc.drv
  /nix/store/d77hbkvsrcqfc929qckfdp7pdfn4cn7n-activate.drv
  /nix/store/8a5ah7xmawijfsnbfw8ry1s3zajliya2-nixos-system-MelDesktop3-26.11.20261023.3ec6363.drv
building '/nix/store/1xzsrr5xn4jg6h0kcp67c1idlg224gar-opencode-desktop-2.2.0+1097e26.drv'...
error: Cannot build '/nix/store/1xzsrr5xn4jg6h0kcp67c1idlg224gar-opencode-desktop-2.2.0+1097e26.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/xznlb50w9zkfm95qp3glv2sqr0494sms-opencode-desktop-2.2.0+1097e26
       Last 25 log lines:
       > node_modules/.bun/ghostty-web@github+anomalyco+ghostty-web+e91e38a/node_modules/ghostty-web/demo/showcase.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/nnm9gdr70ihc6zc9298mzz8jpcgaciql-bash-5.3p20/bin/bash"
       > node_modules/.bun/ghostty-web@github+anomalyco+ghostty-web+e91e38a/node_modules/ghostty-web/scripts/build-wasm.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/nnm9gdr70ihc6zc9298mzz8jpcgaciql-bash-5.3p20/bin/bash"
       > node_modules/.bun/[email protected]+6c6101fa9d9a1fb4/node_modules/oxlint/bin/oxlint: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/@[email protected]+759ce506b1ed1a42/node_modules/@protobuf-ts/plugin/bin/protoc-gen-dump: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/@[email protected]+759ce506b1ed1a42/node_modules/@protobuf-ts/plugin/bin/protoc-gen-ts: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/[email protected]/node_modules/oxlint-tsgolint/bin/tsgolint.js: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/[email protected]/node_modules/regjsparser/bin/parser: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/[email protected]/node_modules/marked/bin/marked.js: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > node_modules/.bun/[email protected]/node_modules/commonmark/bin/commonmark: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/j1j9b0w3mhpccdli73ycj5w7nf6fkzqz-nodejs-24.21.0/bin/node"
       > patching script interpreter paths in packages/ai/node_modules packages/app/node_modules packages/cli/node_modules packages/client/node_modules packages/codemode/node_modules packages/core/node_modules packages/desktop/node_modules packages/gui-plugins/node_modules packages/http-recorder/node_modules packages/httpapi-codegen/node_modules packages/latex/node_modules packages/merman/node_modules packages/patchmark/node_modules packages/plugin-browser/node_modules packages/plugin/node_modules packages/protocol/node_modules packages/schema/node_modules packages/script/node_modules packages/server/node_modules packages/session-ui/node_modules packages/simulation/node_modules packages/theme/node_modules packages/tui/node_modules packages/ui/node_modules packages/util/node_modules
       > $ bun run script/build.ts
       > Copied prod icons from ./icons/prod to resources/icons
       > Generated metainfo for prod at resources/ai.opencode.desktop.metainfo.xml
       > 20 | await $`bun ./script/copy-metainfo.ts ${channel}`
       > 21 |
       > 22 | const built = await exists(path.join(cli, getCurrentCli().package.replace("@opencode/", "")))
       > 23 |
       > 24 | if (channel === "prod" && !built)
       > 25 |   throw new Error(`Production desktop builds bundle the CLI from ${cli}; build it first`)
       >                  ^
       > error: Production desktop builds bundle the CLI from /build/source/packages/cli/dist; build it first
       >       at /build/source/packages/desktop/script/build.ts:25:13
       > 
       > Bun v1.4.2 (Linux x64)
       > error: script "build" exited with code 1
       For full logs, run:
         nix log /nix/store/1xzsrr5xn4jg6h0kcp67c1idlg224gar-opencode-desktop-2.2.0+1097e26.drv
error: Cannot build '/nix/store/mn53crrqjszq8g4iyhwqp8p6js7cfa7w-system-path.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/j1badjm62n5h4m8h538glk6ay48cr6xd-system-path
error: Cannot build '/nix/store/8a5ah7xmawijfsnbfw8ry1s3zajliya2-nixos-system-MelDesktop3-26.11.20261023.3ec6363.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/hzjign2vac4k3wyp4aajcvv56974a16z-nixos-system-MelDesktop3-26.11.20261023.3ec6363
Traceback (most recent call last):
  File "/nix/store/7dbpy71z609raq51wv5m226acm62ril3-nixos-rebuild-ng-26.11/lib/python3.14/site-packages/nixos_rebuild/__init__.py", line 445, in main
    execute(sys.argv)
    ~~~~~~~^^^^^^^^^^
  File "/nix/store/7dbpy71z609raq51wv5m226acm62ril3-nixos-rebuild-ng-26.11/lib/python3.14/site-packages/nixos_rebuild/__init__.py", line 408, in execute
    services.build_and_activate_system(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        action=action,
        ^^^^^^^^^^^^^^
    ...<6 lines>...
        grouped_nix_args=grouped_nix_args,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/nix/store/7dbpy71z609raq51wv5m226acm62ril3-nixos-rebuild-ng-26.11/lib/python3.14/site-packages/nixos_rebuild/services.py", line 327, in build_and_activate_system
    path_to_config = _build_system(
        attr=attr,
    ...<5 lines>...
        grouped_nix_args=grouped_nix_args,
    )
  File "/nix/store/7dbpy71z609raq51wv5m226acm62ril3-nixos-rebuild-ng-26.11/lib/python3.14/site-packages/nixos_rebuild/services.py", line 184, in _build_system
    path_to_config = nix.build_flake(
        attr,
    ...<3 lines>...
        | grouped_nix_args.flake_eval_flags,
    )
  File "/nix/store/7dbpy71z609raq51wv5m226acm62ril3-nixos-rebuild-ng-26.11/lib/python3.14/site-packages/nixos_rebuild/nix.py", line 95, in build_flake
    r = run_wrapper(run_args, stdout=PIPE)
  File "/nix/store/7dbpy71z609raq51wv5m226acm62ril3-nixos-rebuild-ng-26.11/lib/python3.14/site-packages/nixos_rebuild/process.py", line 182, in run_wrapper
    r = subprocess.run(
        final_args,
    ...<5 lines>...
        **kwargs,
    )
  File "/nix/store/xahxrjs30p3mw0a42bqg9ikgkikskw8m-python3-3.14.8/lib/python3.14/subprocess.py", line 578, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command flakes', 'build', '--print-out-paths', '/etc/nixos#nixosConfigurations."MelDesktop3".config.system.build.toplevel', '-v', '--show-trace']' returned non-zero exit status 1.

Operating System

github:NixOS/nixpkgs/nixos-unstable (NixOS 26.11, Linux Kernel 7.2.10)

Terminal

n/a

Activity

  1. opencode-agent commented on Oct 27, 2026

    @opencode-agent
    Contributor

    Thanks for the report. I reproduced this on 2.2.0, and it still happens on the latest dev (86976449c).

    Nix isn't available in our sandbox, so the script below replays the relevant part of the opencode-desktop derivation's buildPhase instead. Like the derivation, it puts the CLI under OPENCODE_CLI_DIST and then runs bun run build with OPENCODE_CHANNEL=prod. It fails with the same error you saw: Production desktop builds bundle the CLI from …/packages/cli/dist; build it first.

    The likely cause is #59046, which changed packages/desktop/script/build.ts to look for the CLI only in packages/cli/dist and dropped support for OPENCODE_CLI_DIST. nix/desktop.nix still puts the CLI there, so the desktop build can't find it.

    Related: #52863, which notes that the Nix CI check never actually builds the derivation, so breakage like this can go unnoticed.

    Reproduction script (nix-desktop-buildphase.sh)
    #!/usr/bin/env bash
    # Replays the relevant part of nix/desktop.nix's buildPhase without Nix.
    # Usage: nix-desktop-buildphase.sh <opencode checkout with deps installed>
    # Env mirrors nix/opencode.nix: OPENCODE_CHANNEL=prod, OPENCODE_VERSION=<version>.
    set -euo pipefail
    SRC="${1:?path to opencode checkout}"
    cd "$SRC/packages/desktop"
    
    export OPENCODE_CHANNEL=prod
    export OPENCODE_VERSION="${OPENCODE_VERSION:-2.2.0}"
    export TMPDIR="$(mktemp -d)"
    
    # --- verbatim logic from nix/desktop.nix buildPhase ---
    export OPENCODE_CLI_DIST="$TMPDIR/desktop-cli"
    cli_package=$(bun -e 'import { getCurrentCli } from "./script/utils.ts"; console.log(getCurrentCli().package.replace("@opencode/", ""))')
    mkdir -p "$OPENCODE_CLI_DIST/$cli_package/bin"
    # stand-in for ${lib.getExe opencode}
    printf '#!/bin/sh\necho %s\n' "$OPENCODE_VERSION" > "$OPENCODE_CLI_DIST/$cli_package/bin/opencode"
    chmod +x "$OPENCODE_CLI_DIST/$cli_package/bin/opencode"
    bun -e 'await Bun.write(process.argv[1], JSON.stringify({ version: process.env.OPENCODE_VERSION }) + "\n")' \
      "$OPENCODE_CLI_DIST/$cli_package/package.json"
    
    echo "staged CLI at: $OPENCODE_CLI_DIST/$cli_package"
    ls -la "$SRC/packages/cli/dist" 2>/dev/null || echo "(packages/cli/dist does not exist, as in the Nix sandbox)"
    
    bun run build

    Run it: bash nix-desktop-buildphase.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions