Skip to content

opencode: 0.0.52 -> 0.1.194#419604

Merged
GaetanLepage merged 8 commits intoNixOS:masterfrom
delafthi:push-royomvsvxpkl
Jul 5, 2025
Merged

opencode: 0.0.52 -> 0.1.194#419604
GaetanLepage merged 8 commits intoNixOS:masterfrom
delafthi:push-royomvsvxpkl

Conversation

@delafthi
Copy link
Contributor

@delafthi delafthi commented Jun 24, 2025

Summary

  • Added myself as a maintainer for the package.
  • Updated opencode from version 0.0.52 to 0.1.126. This update includes several important changes:

Details

  • The project was forked due to this issue.
  • Since most of the project was rewritten in TypeScript and built with Bun, I changed the build process to download precompiled binaries instead of building from source.
  • While this is not an ideal solution, I tried to base this approach on the method used for helix-gpt to manage Bun packaging. However, I was unable to get the sharp dependency to compile, and I couldn’t find any existing references or solutions to this problem. As a result, using prebuilt binaries is the current workaround until a better build process for Bun-based packages is available.
  • This PR includes breaking changes to the package. However, since the package is still in early development, I believe updating the release notes is not necessary.

Notes

I'll also add a home-manager module -> see nix-community/home-manager#7320


Please let me know if you need any additional information or testing!

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.first-time contribution This PR is the author's first one; please be gentle! 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` labels Jun 24, 2025
@repparw
Copy link
Contributor

repparw commented Jun 25, 2025

mind updating to v0.1.136?

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jun 25, 2025
@repparw repparw requested a review from GaetanLepage June 26, 2025 01:37
Copy link
Contributor

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for handling this non-trivial update!

@GaetanLepage
Copy link
Contributor

It's unfortunate we have to fetch the prebuilt binaries...
What was the exact problem you encountered with sharp? Can you share logs?

@thdxr
Copy link

thdxr commented Jun 26, 2025

so i think what's adding to the difficulty is we have our cloud stuff in the same repo. opencode itself does not use sharp it's the remote stuff that does

i'm wondering of bun install --filter=opencode would successfully just install packages for opencode itself

@delafthi
Copy link
Contributor Author

delafthi commented Jun 26, 2025

I currently don’t have access to the logs. @thdxr, thanks for pointing that out. I'll try this and provide feedback as soon as I have an update and also update to the most recent opencode version.

@kesor
Copy link

kesor commented Jun 27, 2025

I am trying to use this derivation, but the binary is just bun. Each time I run opencode -h all I get is bun, opencode --version, 1.2.17, which is bun's version.

Doesn't the opencode project provide the actual project in its releases? Why would they package bun?!

@delafthi
Copy link
Contributor Author

I am trying to use this derivation, but the binary is just bun. Each time I run opencode -h all I get is bun, opencode --version, 1.2.17, which is bun's version.

Doesn't the opencode project provide the actual project in its releases? Why would they package bun?!

I’ll try to push an update tomorrow to build opencode from source instead of just installing the binaries, so probably this issue should be resolved then.

@delafthi
Copy link
Contributor Author

@thdxr bun install --filter=opencode worked 🎉 — opencode can now be built from source!

A few notes about the package declaration, which is a bit more complicated:

@repparw repparw requested a review from GaetanLepage June 29, 2025 14:42
@delafthi
Copy link
Contributor Author

delafthi commented Jun 29, 2025

@GaetanLepage I also resolved your previous comments about the short description and the version check.

@repparw
Copy link
Contributor

repparw commented Jun 29, 2025

error: hash mismatch in fixed-output derivation '/nix/store/1wz3fhhx76891alvvhkjpwbpyszxq2zx-opencode-0.1.162-node-modules.drv':
         specified: sha256-WiOFWCpB9aQ4TvvOSoaVHzt6KBbEjQMjDs2LDm38/B4=
            got:    sha256-DQ259QnYp04xbnopqoXUh4b0JVXoJEUvfYIC084oH0M=
error: 1 dependencies of derivation '/nix/store/mbfjc7zp4vmw12xn6p2clc0jm4x21gps-opencode-0.1.162.drv' failed to build
error: 1 dependencies of derivation '/nix/store/1ghcywz6f6bv2zymz78dk1wjal85f92v-review-shell.drv' failed to build

I'm getting this, not sure why? Does it work on your side?

@delafthi
Copy link
Contributor Author

Yes, the hash of opencode-node-modules changes sometimes, though the exact reason is unclear to me. I encountered this myself and had to update the hash multiple times during testing.

It might be related to the system architecture. For reference, I built on both aarch64-darwin and aarch64-linux. Could you let me know which system you’re building on? That might help us pinpoint the cause.

@repparw
Copy link
Contributor

repparw commented Jun 29, 2025

this one was on x64 Linux

@delafthi delafthi changed the title opencode: 0.0.52 -> 0.1.126 opencode: 0.0.52 -> 0.1.162 Jun 29, 2025
@delafthi
Copy link
Contributor Author

Indeed, the hash value differs across systems. I'm not sure why it worked on my aarch64-linux setup with the same hash. The latest update should resolve this issue.

@delafthi
Copy link
Contributor Author

The output hash of opencode-node-modules has just changed, causing the build to fail. I need to investigate further to determine why the build process for this package is not reproducible.

@repparw
Copy link
Contributor

repparw commented Jun 29, 2025

don't know how this gets created in upstream, but can't we get those node modules some other way? changing 6 hashes on package upgrade at this point looks wonky haha

@delafthi
Copy link
Contributor Author

don't know how this gets created in upstream, but can't we get those node modules some other way? changing 6 hashes on package upgrade at this point looks wonky haha

I agree. Let's hope for buildBunModule.

@GaetanLepage
Copy link
Contributor

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 419604
Commit: 4721ddd76f0ebd076f1e782ad3d22ec21f6bffe2


x86_64-linux

✅ 1 package built:
  • opencode

aarch64-linux

✅ 1 package built:
  • opencode

x86_64-darwin

✅ 1 package built:
  • opencode

aarch64-darwin

✅ 1 package built:
  • opencode

Copy link
Contributor

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

@GaetanLepage GaetanLepage requested a review from kirillrdy July 2, 2025 22:57
@kirillrdy
Copy link
Member

https://github.com/NixOS/nixpkgs/pull/419604/checks?check_run_id=45270188598

@delafthi
Copy link
Contributor Author

delafthi commented Jul 3, 2025

Added the following changes:

  • Updated from 0.1.176 to 0.1.181
  • Replaced stdenv with stdenvNoCC
  • Moved subpackages into main derivation to enable updating subpackages with nix-update-script
  • Fixed version test, by providing a temporary HOME directory

delafthi added 2 commits July 3, 2025 14:06
- Replaced `stdenv` with `stdenvNoCC`
- Moved subpackages into main derivation to enable updating subpackages with `nix-update-script`
- Fixed version test, by providing a temporary `HOME` directory
@delafthi delafthi changed the title opencode: 0.0.52 -> 0.1.176 opencode: 0.0.52 -> 0.1.182 Jul 3, 2025
@flacks
Copy link
Contributor

flacks commented Jul 3, 2025

Fast-moving target... already at 0.1.183...

@repparw
Copy link
Contributor

repparw commented Jul 3, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 419604
Commit: 872fd0c102ca5f07a4bf140964f7f32ffdae6b20


x86_64-linux

✅ 1 package built:
  • opencode

@repparw
Copy link
Contributor

repparw commented Jul 3, 2025

is there a nixpkgs policy about update frequency?

opencode releases a lot of versions, mostly small changes. should be update every x days at a maximum or something?

@flacks
Copy link
Contributor

flacks commented Jul 3, 2025

not that I've seen, but I could be wrong. it's just maintainer (and reviewer) burden 😄

@flacks
Copy link
Contributor

flacks commented Jul 3, 2025

at some point, you have to commit!

@repparw
Copy link
Contributor

repparw commented Jul 3, 2025

at some point, you have to commit!

sure, I mean after this PR. now merging x or x+1 is not really important

@flacks
Copy link
Contributor

flacks commented Jul 3, 2025

well... I think everything inbetween ~0.1.172 and 0.1.183 would take like 5 minutes before being able to properly post a message when using github copilot auth. so it depends on maintainer's urgency I guess. but people can always overlay/override locally unless dependencies or build change.

@delafthi delafthi changed the title opencode: 0.0.52 -> 0.1.182 opencode: 0.0.52 -> 0.1.185 Jul 3, 2025
@debashisbiswas
Copy link

On the current version, I'm getting the following build error on both x86_64-linux and aarch64-darwin:

error: builder for '/nix/store/cnc3w1jzjc5f57mnm2qpdva8bny6p83y-opencode-node_modules-0.1.185.drv' failed with exit code 1;
       last 11 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/px7ziy0kpds29mh0ih46ab9lagp14py8-source
       > source root is source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: buildPhase
       > bun install v1.2.17 (282dda62)
       > Resolving dependencies
       > Resolved, downloaded and extracted [115]
       > error: lockfile had changes, but lockfile is frozen
       > note: try re-running without --frozen-lockfile and commit the updated lockfile
       For full logs, run:
         nix log /nix/store/cnc3w1jzjc5f57mnm2qpdva8bny6p83y-opencode-node_modules-0.1.185.drv
error (ignored): error: cannot unlink "/private/tmp/nix-build-opencode-tui-0.1.185-go-modules.drv-1/go/pkg/mod/github.com": Directory not empty
error: 1 dependencies of derivation '/nix/store/lywywsgbyx94s7ix05wxhv4n6qysrn1c-opencode-0.1.185.drv' failed to build

As per the bun documentation:

For reproducible installs, use --frozen-lockfile. This will install the exact versions of each package specified in the lockfile. If your package.json disagrees with bun.lock, Bun will exit with an error. The lockfile will not be updated.

I observed that in v0.1.185:

I did a bun install to create a new lockfile and compared it with the existing one: the new lockfile uses 1.2.18 while the old uses 1.2.17. Perhaps this is a case where "your package.json disagrees with bun.lock", as package.json's latest in this case is now 1.2.18, disagreeing with bun.lock's 1.2.17 and causing --frozen-lockfile to fail, but I'm not sure. This may also help explain the inconsistent node_modules hashes earlier in PR, though it doesn't seem like this dependency has released new versions often enough to explain the frequency of that issue.

@delafthi
Copy link
Contributor Author

delafthi commented Jul 4, 2025

Yes, I have the same issue and it seems that there is no way to ignore that error and just build based on the lockfile.

@delafthi
Copy link
Contributor Author

delafthi commented Jul 5, 2025

On the current version, I'm getting the following build error on both x86_64-linux and aarch64-darwin:

error: builder for '/nix/store/cnc3w1jzjc5f57mnm2qpdva8bny6p83y-opencode-node_modules-0.1.185.drv' failed with exit code 1;
       last 11 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/px7ziy0kpds29mh0ih46ab9lagp14py8-source
       > source root is source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: buildPhase
       > bun install v1.2.17 (282dda62)
       > Resolving dependencies
       > Resolved, downloaded and extracted [115]
       > error: lockfile had changes, but lockfile is frozen
       > note: try re-running without --frozen-lockfile and commit the updated lockfile
       For full logs, run:
         nix log /nix/store/cnc3w1jzjc5f57mnm2qpdva8bny6p83y-opencode-node_modules-0.1.185.drv
error (ignored): error: cannot unlink "/private/tmp/nix-build-opencode-tui-0.1.185-go-modules.drv-1/go/pkg/mod/github.com": Directory not empty
error: 1 dependencies of derivation '/nix/store/lywywsgbyx94s7ix05wxhv4n6qysrn1c-opencode-0.1.185.drv' failed to build

As per the bun documentation:

For reproducible installs, use --frozen-lockfile. This will install the exact versions of each package specified in the lockfile. If your package.json disagrees with bun.lock, Bun will exit with an error. The lockfile will not be updated.

I observed that in v0.1.185:

* bun.lock includes the dependency `@types/bun` at [version `1.2.17`](https://github.com/sst/opencode/blob/v0.1.185/bun.lock?rgh-link-date=2025-07-04T07%3A09%3A08Z#L56)

* opencode's package.json uses `@types/bun` at [version `latest`](https://github.com/sst/opencode/blob/v0.1.185/packages/opencode/package.json?rgh-link-date=2025-07-04T07%3A09%3A08Z#L21).

I did a bun install to create a new lockfile and compared it with the existing one: the new lockfile uses 1.2.18 while the old uses 1.2.17. Perhaps this is a case where "your package.json disagrees with bun.lock", as package.json's latest in this case is now 1.2.18, disagreeing with bun.lock's 1.2.17 and causing --frozen-lockfile to fail, but I'm not sure. This may also help explain the inconsistent node_modules hashes earlier in PR, though it doesn't seem like this dependency has released new versions often enough to explain the frequency of that issue.

Upstream updated the lockfile. Thus, this issue is fixed in 0.1.194.

@delafthi delafthi changed the title opencode: 0.0.52 -> 0.1.185 opencode: 0.0.52 -> 0.1.194 Jul 5, 2025
@repparw
Copy link
Contributor

repparw commented Jul 5, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 419604


x86_64-linux

✅ 1 package built:
  • opencode

@GaetanLepage
Copy link
Contributor

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 419604
Commit: 4acc22caf616f5958042d2746921f39203277edc


x86_64-linux

✅ 1 package built:
  • opencode

aarch64-linux

✅ 1 package built:
  • opencode

x86_64-darwin

✅ 1 package built:
  • opencode

aarch64-darwin

✅ 1 package built:
  • opencode

Copy link
Contributor

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job everyone.

@GaetanLepage GaetanLepage merged commit 915b100 into NixOS:master Jul 5, 2025
23 of 27 checks passed
@delafthi delafthi deleted the push-royomvsvxpkl branch July 5, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons. 12.first-time contribution This PR is the author's first one; please be gentle!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants