Skip to content

fix(nix): pass NODE_EXTRA_CA_CERTS through to bun in node_modules build#18405

Open
HacknBashe wants to merge 2 commits intoanomalyco:devfrom
HacknBashe:fix/nix-node-extra-ca-certs
Open

fix(nix): pass NODE_EXTRA_CA_CERTS through to bun in node_modules build#18405
HacknBashe wants to merge 2 commits intoanomalyco:devfrom
HacknBashe:fix/nix-node-extra-ca-certs

Conversation

@HacknBashe
Copy link

@HacknBashe HacknBashe commented Mar 20, 2026

Issue for this PR

Closes #18407

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds NODE_EXTRA_CA_CERTS to impureEnvVars in the node_modules fixed-output derivation

Corporate environments with TLS inspection proxies inject their own CA certificates into the chain. This causes bun to fail with SELF_SIGNED_CERT_IN_CHAIN when fetching GitHub tarballs (e.g. ghostty-web) during the nix build.

lib.fetchers.proxyImpureEnvVars already includes NIX_SSL_CERT_FILE, but bun ignores that and only reads NODE_EXTRA_CA_CERTS. Without it in impureEnvVars, there's no way to pass a custom CA bundle through to bun in the sandboxed build.

How did you verify your code works?

No longer see self signed cert error when building my nix flake against my local opencode repo with this change.

    opencode = {
      url = "path:/Users/**/src/opencode";
      inputs.nixpkgs.follows = "nixpkgs";
    };

Screenshots / recordings

error: Cannot build '/nix/store/gkas8rz3acaf0ki1yxgh2p5g5vsn33yg-opencode-node_modules-1.2.27-dirty.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/p4f478rz4w49p6jlywsrkgw4kbmnz427-opencode-node_modules-1.2.27-dirty
       Last 11 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/n45409qd16qldkr02dn2f8rq4wj7bd73-source
       > source root is source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: buildPhase
       > bun install v1.3.10 (30e609e0)
       > Resolving dependencies
       > Resolved, downloaded and extracted [434]
       > error: SELF_SIGNED_CERT_IN_CHAIN downloading tarball ghostty-web@github:anomalyco/ghostty-web#main
       > error: ghostty-web@github:anomalyco/ghostty-web#main failed to resolve

old error that is gone

===

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 20, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Mar 20, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@HacknBashe HacknBashe force-pushed the fix/nix-node-extra-ca-certs branch from 86855e4 to c16b605 Compare March 20, 2026 16:06
@HacknBashe HacknBashe marked this pull request as ready for review March 20, 2026 16:19
@HacknBashe HacknBashe marked this pull request as draft March 21, 2026 02:15
HacknBashe and others added 2 commits March 20, 2026 22:15
Corporate environments with TLS inspection proxies cause bun to fail
with SELF_SIGNED_CERT_IN_CHAIN during the node_modules build.
NIX_SSL_CERT_FILE is already passed through via proxyImpureEnvVars, but
bun only reads NODE_EXTRA_CA_CERTS. This bridges the two in the build
phase so no external daemon configuration is needed.
Remove comments about bridging NIX_SSL_CERT_FILE to NODE_EXTRA_CA_CERTS.
@HacknBashe HacknBashe force-pushed the fix/nix-node-extra-ca-certs branch from 3e74a90 to 3f8a32d Compare March 21, 2026 02:15
@HacknBashe HacknBashe marked this pull request as ready for review March 21, 2026 02:16
@HacknBashe
Copy link
Author

I think my opencode agent requested this review? Not sure why you were pinged adam, sorry

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nix build fails behind corporate TLS proxy: bun SELF_SIGNED_CERT_IN_CHAIN

1 participant