When built from the flake, opencode package is extremely large (4GB+) #3176

Open
opened 2026-02-16 17:38:59 -05:00 by yindo · 5 comments
Owner

Originally created by @palekiwi on GitHub (Nov 28, 2025).

Originally assigned to: @rekram1-node on GitHub.

First off, thanks so much for the addition of the flake.nix to the repo. It's been a monumental piece of work that I absolutely rely on.

However, I've noticed that the package built from the flake.nix takes up over 4GB of space.

Below is an AI generated report that may be helpful.

Summary

The OpenCode package is 4.0 GiB, which is excessive. Investigation shows that all platform-specific optional dependencies are being bundled instead of just the required platform.

Environment

  • OpenCode version: v1.0.119
  • Package manager: Bun
  • Platform: Linux x64
  • Installation: Via Nix flake from github:sst/opencode

Issue Details

The OpenCode Nix store package is 4.0 GiB:

$ nix path-info -Sh github:sst/opencode
/nix/store/q3p8pk2qk3ydsi2fdvnjl6raiydwdgyi-opencode-1.0.119  4.0 GiB

Nearly all of this size (4.2GB) comes from node_modules/.bun/ containing platform-specific binaries for all platforms instead of just Linux x64.

Breakdown of Bloat

Platform-specific binaries (only Linux x64 needed, but all platforms included):

  • SST binaries: ~470MB total (6 platforms)

    • sst-darwin-arm64: 77M
    • sst-darwin-x64: 82M
    • sst-linux-arm64: 75M
    • sst-linux-x64: 80M (only one needed)
    • sst-win32-arm64: 75M
    • sst-win32-x64: 81M
  • Cloudflare Workerd: ~500MB total (5 platforms)

    • @cloudflare/workerd-darwin-64: 99M
    • @cloudflare/workerd-darwin-arm64: 95M
    • @cloudflare/workerd-linux-64: 112M (only one needed)
    • @cloudflare/workerd-linux-arm64: 116M
    • @cloudflare/workerd-windows-64: 80M
  • Pagefind: ~390MB total (6 platforms)

    • @pagefind/darwin-arm64: 63M
    • @pagefind/darwin-x64: 63M
    • @pagefind/freebsd-x64: 66M
    • @pagefind/linux-arm64: 65M
    • @pagefind/linux-x64: 66M (only one needed)
    • @pagefind/windows-x64: 63M
  • Turbo: ~200MB total (6 platforms)

    • turbo-darwin-64: 31M
    • turbo-darwin-arm64: 27M
    • turbo-linux-64: 33M (only one needed)
    • turbo-linux-arm64: 29M
    • turbo-windows-64: 39M
    • turbo-windows-arm64: 39M

Other large dependencies:

  • @ibm/plex fonts: 203MB
  • aws-sdk: 101MB
  • cloudflare: 53MB
  • three: 32MB

Total: 1,898 packages in node_modules/.bun/

Originally created by @palekiwi on GitHub (Nov 28, 2025). Originally assigned to: @rekram1-node on GitHub. First off, thanks so much for the addition of the `flake.nix` to the repo. It's been a monumental piece of work that I absolutely rely on. However, I've noticed that the package built from the `flake.nix` takes up over 4GB of space. Below is an AI generated report that may be helpful. ## Summary The OpenCode package is 4.0 GiB, which is excessive. Investigation shows that all platform-specific optional dependencies are being bundled instead of just the required platform. ### Environment - **OpenCode version**: v1.0.119 - **Package manager**: Bun - **Platform**: Linux x64 - **Installation**: Via Nix flake from `github:sst/opencode` ### Issue Details The OpenCode Nix store package is **4.0 GiB**: ```bash $ nix path-info -Sh github:sst/opencode /nix/store/q3p8pk2qk3ydsi2fdvnjl6raiydwdgyi-opencode-1.0.119 4.0 GiB ``` Nearly all of this size (4.2GB) comes from `node_modules/.bun/` containing platform-specific binaries for **all platforms** instead of just Linux x64. ### Breakdown of Bloat **Platform-specific binaries (only Linux x64 needed, but all platforms included):** - **SST binaries**: ~470MB total (6 platforms) - `sst-darwin-arm64`: 77M - `sst-darwin-x64`: 82M - `sst-linux-arm64`: 75M - `sst-linux-x64`: 80M ✅ (only one needed) - `sst-win32-arm64`: 75M - `sst-win32-x64`: 81M - **Cloudflare Workerd**: ~500MB total (5 platforms) - `@cloudflare/workerd-darwin-64`: 99M - `@cloudflare/workerd-darwin-arm64`: 95M - `@cloudflare/workerd-linux-64`: 112M ✅ (only one needed) - `@cloudflare/workerd-linux-arm64`: 116M - `@cloudflare/workerd-windows-64`: 80M - **Pagefind**: ~390MB total (6 platforms) - `@pagefind/darwin-arm64`: 63M - `@pagefind/darwin-x64`: 63M - `@pagefind/freebsd-x64`: 66M - `@pagefind/linux-arm64`: 65M - `@pagefind/linux-x64`: 66M ✅ (only one needed) - `@pagefind/windows-x64`: 63M - **Turbo**: ~200MB total (6 platforms) - `turbo-darwin-64`: 31M - `turbo-darwin-arm64`: 27M - `turbo-linux-64`: 33M ✅ (only one needed) - `turbo-linux-arm64`: 29M - `turbo-windows-64`: 39M - `turbo-windows-arm64`: 39M **Other large dependencies:** - `@ibm/plex` fonts: 203MB - `aws-sdk`: 101MB - `cloudflare`: 53MB - `three`: 32MB **Total**: 1,898 packages in `node_modules/.bun/`
yindo added the help-wantednix labels 2026-02-16 17:38:59 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 28, 2025):

This issue might be related to existing nix flake issues. Please check:

  • #4575: opencode binary on macOS arm64 is 0 byte large when building from nix flake (similar flake build problems, though with different symptoms)
  • #4498: Hash mismatch when using opencode flake.nix (related to flake.nix build issues)

These are related to Nix flake build problems. The root cause might be shared - potentially issues with how dependencies are bundled in the Nix sandbox environment.

@github-actions[bot] commented on GitHub (Nov 28, 2025): This issue might be related to existing nix flake issues. Please check: - #4575: opencode binary on macOS arm64 is 0 byte large when building from nix flake (similar flake build problems, though with different symptoms) - #4498: Hash mismatch when using opencode flake.nix (related to flake.nix build issues) These are related to Nix flake build problems. The root cause might be shared - potentially issues with how dependencies are bundled in the Nix sandbox environment.
Author
Owner

@rekram1-node commented on GitHub (Nov 28, 2025):

seems like the nix script has some bugs in it a lot of those packages shouldnt be in the executable

@rekram1-node commented on GitHub (Nov 28, 2025): seems like the nix script has some bugs in it a lot of those packages shouldnt be in the executable
Author
Owner

@podocarp commented on GitHub (Dec 16, 2025):

Here is the resulting directory structure.

└╼[nix-shell:/nix/store/yfm1d0h42byzy2iawwaghw58bwqys6bd-opencode-1.0.164]$ tree
.
├── bin
│   └── opencode
└── lib
    └── opencode
        ├── dist
        │   ├── src
        │   │   ├── cli
        │   │   │   └── cmd
        │   │   │       └── tui
        │   │   │           ├── parser.worker.js
        │   │   │           └── worker.js
        │   │   └── index.js
        │   ├── tree-sitter-3jzf13jk.wasm
        │   └── tree-sitter-bash-hq5s6fxb.wasm
        └── node_modules
            └── @opentui
                ├── core -> ../.bun/@opentui+core@0.0.0-20251211-4403a69a+81ecd8642a1892ca/node_modules/@opentui/core
                ├── core-darwin-arm64 -> ../.bun/@opentui+core-darwin-arm64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-darwin-arm64
                ├── core-darwin-x64 -> ../.bun/@opentui+core-darwin-x64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-darwin-x64
                ├── core-linux-arm64 -> ../.bun/@opentui+core-linux-arm64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-linux-arm64
                ├── core-linux-x64 -> ../.bun/@opentui+core-linux-x64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-linux-x64
                ├── core-win32-arm64 -> ../.bun/@opentui+core-win32-arm64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-win32-arm64
                ├── core-win32-x64 -> ../.bun/@opentui+core-win32-x64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-win32-x64
                └── solid -> ../.bun/@opentui+solid@0.0.0-20251211-4403a69a+897ebc1644d3edd0/node_modules/@opentui/solid

The binary in bin is only 52K and is the correct one.

The culprit, as always, is node_modules

$ du -hs *
15M	dist
4.3G	node_modules


$ ls
core  core-darwin-arm64  core-darwin-x64  core-linux-arm64  core-linux-x64  core-win32-arm64  core-win32-x64  solid

@podocarp commented on GitHub (Dec 16, 2025): Here is the resulting directory structure. ``` └╼[nix-shell:/nix/store/yfm1d0h42byzy2iawwaghw58bwqys6bd-opencode-1.0.164]$ tree . ├── bin │   └── opencode └── lib └── opencode ├── dist │   ├── src │   │   ├── cli │   │   │   └── cmd │   │   │   └── tui │   │   │   ├── parser.worker.js │   │   │   └── worker.js │   │   └── index.js │   ├── tree-sitter-3jzf13jk.wasm │   └── tree-sitter-bash-hq5s6fxb.wasm └── node_modules └── @opentui ├── core -> ../.bun/@opentui+core@0.0.0-20251211-4403a69a+81ecd8642a1892ca/node_modules/@opentui/core ├── core-darwin-arm64 -> ../.bun/@opentui+core-darwin-arm64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-darwin-arm64 ├── core-darwin-x64 -> ../.bun/@opentui+core-darwin-x64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-darwin-x64 ├── core-linux-arm64 -> ../.bun/@opentui+core-linux-arm64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-linux-arm64 ├── core-linux-x64 -> ../.bun/@opentui+core-linux-x64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-linux-x64 ├── core-win32-arm64 -> ../.bun/@opentui+core-win32-arm64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-win32-arm64 ├── core-win32-x64 -> ../.bun/@opentui+core-win32-x64@0.0.0-20251211-4403a69a/node_modules/@opentui/core-win32-x64 └── solid -> ../.bun/@opentui+solid@0.0.0-20251211-4403a69a+897ebc1644d3edd0/node_modules/@opentui/solid ``` The binary in `bin` is only 52K and is the correct one. The culprit, as always, is node_modules ``` $ du -hs * 15M dist 4.3G node_modules $ ls core core-darwin-arm64 core-darwin-x64 core-linux-arm64 core-linux-x64 core-win32-arm64 core-win32-x64 solid ```
Author
Owner

@gigamonster256 commented on GitHub (Jan 20, 2026):

should be fixed, binary is now 142MB and package only includes the binary itself, shell completions, and the config schema.json

@gigamonster256 commented on GitHub (Jan 20, 2026): should be fixed, binary is now 142MB and package only includes the binary itself, shell completions, and the config schema.json
Author
Owner

@mausch commented on GitHub (Feb 5, 2026):

yep I think this can be closed now.

nix build github:anomalyco/opencode/v1.1.51 gives me 142MB

@mausch commented on GitHub (Feb 5, 2026): yep I think this can be closed now. `nix build github:anomalyco/opencode/v1.1.51` gives me 142MB
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3176