nzbr / pnpm2nix-nzbr

Build packages using pnpm with nix
ISC License
63 stars 23 forks source link

Add support for pnpm workspaces #35

Open iteratee opened 8 months ago

iteratee commented 8 months ago

Currently a monorepo with multiple components doesn't work with the current pnpm2nix.

You can try to build the entire monorepo, but then fail to copy out all of the node_modules directories or you can try and build individual components, but pnpm complains if you pass it the project-wide lockfile for a specific component.

Add workspace and components as an alternative to src. When building the node-modules derivation, copy out the node_modules directory for every named component in addition to the node_modules directory at the root.

When building, pass the list of components as a filter to pnpm run --recursive ${script}. When doing the install, allow the user to specify which directories to copy out, with a default of ${component}/dist for each component.

Currently doesn't have support for building individual components as separate derivations with shared pnpm-store and node-modules derivations.

This works for building a project where we needed workspace support.