Skip to content

npmFixupHook: extract from npmInstallHook - #335504

Closed
lelgenio wants to merge 1 commit into
NixOS:masterfrom
lelgenio:npm-fixup-phase-init
Closed

lelgenio wants to merge 1 commit into
NixOS:masterfrom
lelgenio:npm-fixup-phase-init

Conversation

@lelgenio

Copy link
Copy Markdown
Contributor

npmInstallHook currently performs a prune step to remove unnecessary dependencies from node_modules.
This behavior makes more sense as the fixupPhase, filling a similar role to stripping binary files.

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

`npmInstallHook` currently performs a prune step to remove unnecessary dependencies from node_modules.
This behavior makes more sense as the `fixupPhase`, filling a similar role to stripping binary files.
@github-actions github-actions Bot added the 6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment label Aug 18, 2024
@lelgenio lelgenio mentioned this pull request Aug 18, 2024
13 tasks
@ofborg ofborg Bot added 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. labels Aug 18, 2024

@doronbehar doronbehar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this, due to what I wrote below, and also because overriding the fixup phase seems wrong. Additionally, I was thinking of this option when I wrote my last comment in #328544 and I decided not to suggest it, because the official stdenv fixup docs state:

The fixup phase performs (Nix-specific) post-processing actions on the files installed under $out by the install phase.


find node_modules -maxdepth 1 -type d -empty -delete

cp -r node_modules "$nodeModulesPath"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this is a bit worrying - The installPhase will run before the fixupPhase, and will copy this directory before the fixup happened.. Then, if you won't run npm prune, you will always get all of the development dependencies in the $packageOut/node_modules... That's probably the reason why the author of this hook saw this part as an nondetachable part of the installation phase.

@lelgenio lelgenio closed this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants