chore(nix): add bun node_modules normalization scripts#1256
Open
xilec wants to merge 1 commit intocjpais:mainfrom
Open
chore(nix): add bun node_modules normalization scripts#1256xilec wants to merge 1 commit intocjpais:mainfrom
xilec wants to merge 1 commit intocjpais:mainfrom
Conversation
Add canonicalize-node-modules.ts and normalize-bun-binaries.ts to .nix/scripts/ for use by nixpkgs and other non-flake Nix builds. These scripts ensure deterministic symlink ordering inside node_modules/.bun/, which is required for reproducible fixed-output derivation hashes when using bun install --cpu="*" --os="*" to fetch all platform variants. Adapted from the opencode package (MIT license).
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Added two TypeScript scripts to
.nix/scripts/that canonicalize bun's internal symlinks insidenode_modules/.bun/:canonicalize-node-modules.ts— rebuildsnode_modules/.bun/node_modules/symlinks in deterministic sorted ordernormalize-bun-binaries.ts— rebuilds.bin/symlinks deterministically based onpackage.jsonbinfieldsAdapted from the opencode package (MIT license).
Why
These scripts are needed for the nixpkgs upstream packaging. Unlike the flake, nixpkgs can't use external tools like bun2nix (it's not merged yet), so the package uses a workaround:
bun install --cpu="*" --os="*"to download all platform variants and get a single hash that works on both Linux and macOS. Bun creates symlinks in non-deterministic order which breaks reproducibility — these scripts fix that.Having them in the Handy repo (rather than in the nixpkgs tree) is the preferred approach, same as opencode does it.
Test plan