-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit lockfile v2 and fix bin links with NPM v7+ #302
Conversation
bdc1af8
to
f1ecc51
Compare
Okay, I think I've got this rebuilding the This should be ready for review/merge and I will be making a companion PR in nixpkgs in a few that brings the |
Lockfile v2 mostly just has a bit of extra metadata and all dependencies are hoisted to the top-level with path-specific keys in a new lock value called "packages". This update emits enough of the format that NPM v7+ seem to be happy enough with it and does not try to rewrite it and cause ENOTCACHED errors with the sandbox. As of NPM v7+, it no longer links bins for the top-level project automatically unless a global install is selected[1][2]. Given a global install would cause more problems than it would solve, I added a simple script to perform the linking ourselves and instructed `npm install` to never link them for consistency. Closes svanderburg#236, svanderburg#293, svanderburg#294 [1]: npm/cli@e46400c#diff-24c01909dabbe2fc000fb5b43d14b511fb335b2f0c2e8e7a671f7d567a33d577R17-R18 [2]: npm/cli#4308
f1ecc51
to
375a055
Compare
Opened PR in nixpkgs as NixOS/nixpkgs#193337 |
Ok, nice contribution! I'll merge it |
What version of node2nix is coming out as? |
This is minor fallout from svanderburg/node2nix#302 which made node2nix handle installing script bins itself (since npm stopped doing that correctly). It seems npm was doing line-ending normalization when installing these files itself, so in addition to making all bins executable we now also do a crlf to lf conversion on them if they are a script with a shebang.
This is minor fallout from svanderburg/node2nix#302 which made node2nix handle installing script bins itself (since npm stopped doing that correctly). It seems npm was doing line-ending normalization when installing these files itself, so in addition to making all bins executable we now also do a crlf to lf conversion on them if they are a script with a shebang. (cherry picked from commit b85c1e3)
Lockfile v2 mostly just has a bit of extra metadata and all dependencies are hoisted to the top-level with path-specific keys in a new lock value called "packages". This update emits enough of the format that NPM v7+ seem to be happy enough with it and does not try to rewrite it and cause
ENOTCACHED
errors with the sandbox.As of NPM v7+, it no longer links bins for the top-level project automatically unless a global install is selected1 (and is not a problem specific to node2nix2). Given a global install would cause more problems than it would solve, I added a simple script to perform the linking ourselves and instructed
npm install
to never link them for consistency.Additionally, this adds a
postRebuild
hook that can be used by packages to run extra build scripts as needed by the project before thenpm install
step prunes dev dependencies (also seems to be a new behavior of NPM v7+, but admittedly this behavior could be due to the fake lock file confusing it a little)Closes #236, closes #293, closes #294
Edit:
Marking as draft until I can get this to work completely with thenodePackages
attrset in nixpkgs