svanderburg / node2nix

Generate Nix expressions to build NPM packages
MIT License
527 stars 100 forks source link

Generate specific list of dependencies for devDependencies #325

Open lfdominguez opened 9 months ago

lfdominguez commented 9 months ago

Hi, thanks for this great project.

I'm really trying hard to build a NextJS project using node2nix. I can't use the package-lock.json because devs don't want to use Nix and use the package-lock version 3 that is not supported by node2nix.

Furthermore, I can suggest that on the node-packages.nix if you use the -d arg to node-nix not to merge the nodeDependencies from devDependencies and dependencies?? My focus is that devDependencies it's in theory only for build process, but not for runtime, then if I need a build step on my project need to execute node2nix with -d and this will add so many dependencies to my runtime final derivation that I don't want.

On the node-packages.nix creation process then can be created the current nodeDependencies but if -d is used then put nodeDependenciesDist with only the dependencies and not the devDependencies. Is this possible?

lfdominguez commented 9 months ago

Right now my workaround is run node2nix two times (a lot of time wasted, but it's only the first time) with different args:

Then on my flake.nix:

nodePackagesDev = import ./node-packages-dev.nix {
  inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
  inherit nodeEnv;
};

nodePackagesDist = import ./node-packages-dist.nix {
  inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
  inherit nodeEnv;
};

nodeDependenciesDev = nodePackagesDev.nodeDependencies.override {
  buildInputs = with pkgs;[ pkg-config vips.dev pixman cairo.dev pango.dev ];
};

nodeDependenciesDist = nodePackagesDist.nodeDependencies.override {
  buildInputs = with pkgs;[ pkg-config vips.dev pixman cairo.dev pango.dev ];
};

And use each one on needed steps of my derivation.