Build failure: opencode
Nixpkgs version
- Unstable (26.11)
Steps to reproduce
- (not sure if needed to reproduce) use nix on darwin
- Configure https proxy with TLS inspection and add CA certificate of the proxy to your config (e.g. with
config.security.pki.certificateswhen using nix-darwin) nix build nixpkgs#opencode.node_modules --no-substitute --rebuild
Can Hydra reproduce this build failure?
No, Hydra cannot reproduce this build failure.
Link to Hydra build job
No response
Relevant log output
structuredAttrs is enabled
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/zisy0rd6d3rm3iwxd0gy8zfhnhl72qwi-source
source root is source
unpackPhase completed in 55 seconds
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
bun install v1.4.4 (38afee6c8)
Resolving dependencies
Resolved, downloaded and extracted [19]
warn: patches/@standard-community%[email protected] no longer applies (@standard-community/standard-openapi is no longer installed)
warn: patches/@ai-sdk%[email protected] no longer applies (@ai-sdk/mistral is no longer installed)
warn: patches/[email protected] no longer applies (gcp-metadata is now 8.1.4)
warn: patches/@ai-sdk%[email protected] no longer applies (@ai-sdk/google is no longer installed)
error: failed to download ghostty-web@github:anomalyco/ghostty-web#e91e38a: SELF_SIGNED_CERT_IN_CHAIN
https://api.github.com/repos/anomalyco/ghostty-web/tarball/e91e38a
error: failed to download @parcel/[email protected]: SELF_SIGNED_CERT_IN_CHAIN
https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz
[...]
error: failed to download [email protected]: SELF_SIGNED_CERT_IN_CHAIN
https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.4.tgz
error: failed to download [email protected]: SELF_SIGNED_CERT_IN_CHAIN
https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz
warn: SELF_SIGNED_CERT_IN_CHAIN downloading tarball @ast-grep/[email protected]
warn: SELF_SIGNED_CERT_IN_CHAIN downloading tarball @ast-grep/[email protected]
[...]
warn: SELF_SIGNED_CERT_IN_CHAIN downloading tarball @pkgjs/[email protected]
Failed to install 1316 packages
Additional context
The reason I did not encounter this earlier was that I downloaded the package from the binary cache. But due to https://github.com/NixOS/nixpkgs/issues/585600 this is currently not possible.
System metadata
- system:
"aarch64-darwin" - host os:
Darwin 25.6.0, macOS 26.6.2 - multi-user?:
yes - sandbox:
no - version:
nix-env (Nix) 2.34.8 - channels(root):
"nixpkgs" - nixpkgs:
/nix/store/v7v3dncmpp062v8xw86vv2asyga4114i-source
Notify maintainers
@delafthi @DuskyElf @graham33 @superherointj
Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)
I assert that this issue is relevant for Nixpkgs
- [x] I assert that this is a bug and not a support request.
- [x] I assert that this is not a duplicate of an existing issue.
- [x] I assert that I have read the NixOS Code of Conduct and agree to abide by it.
- [x] I assert that I have read the automation/AI policy and that this issue report complies with it.
Is this issue important to you?
Add a :+1: reaction to issues you find important.
I can solve this locally by overwriting the build phase:
pkgs.opencode.overrideAttrs (prev: {
node_modules = prev.node_modules.overrideAttrs (nm: {
buildPhase = ''
export NODE_EXTRA_CA_CERTS="$NIX_SSL_CERT_FILE"
''
+ nm.buildPhase;
});
});
Maybe we could add the export to the definition in nixpkgs?
This isn't really an opencode bug. bun install runs in the fixed-output node_modules derivation, which is allowed to use the network. Nix forwards the proxy CA as NIX_SSL_CERT_FILE (#303307) and makes that bundle available inside the build. But bun reads SSL_CERT_FILE, not NIX_SSL_CERT_FILE, and stdenv sets SSL_CERT_FILE=/no-cert-file.crt. So the bundle Nix handed over is invisible to bun. cacert's setup hook copies one to the other (d390013), and this FOD doesn't pull in cacert. The override works because it does that bridge by hand.
Fix:
nativeBuildInputs = [ bun cacert writableTmpDirAsHomeHook ];
The hook keeps your CA when the path is readable, otherwise it falls back to the nixpkgs bundle. The FOD output path doesn't change, so cached node_modules stay valid. Against a self-signed local registry, the same derivation fails with DEPTH_ZERO_SELF_SIGNED_CERT without cacert and installs with it.
Hydra doesn't hit this, it has direct internet. It only shows up on local builds, and #585600 is why 2.2.5+ needs them.
The Nix side is the real gap: the bundle is mounted but never put into the build environment. That's NixOS/nix#10783 and NixOS/nix#12698, with general tracking in #8247 and the darwin reports in #409848 and #200450. Other fetchers hit the same thing, see #443454, #420608, #518315 and #304483. Every bun install FOD shares it, so a hook in the bun package would fix the rest. stdenv's SSL_CERT_FILE default should also come from NIX_SSL_CERT_FILE, but that's a world rebuild.