I’m trying to set up a
flake.nix file for a projects. I see a couple of different conflicting things online on how to best tackle the situation. The two normal-est I see right now are to either use
node2nix or leverage your
package-lock.json and just install via
npm as a part of
mkDerivation. Neither of these solution seem to be working for me and I don’t really have my bearings on how to read the error outputs or effectively use the right keywords on a web search. I’m also curious if making
node_modules a separate “app” in the Flake world is what makes the most sense.
In my case, I’m trying to use
email@example.com (v1.x in nixpkgs is missing features I need) to compile and bundle various sources together for distribution for a static site.
When I tried
node2nix I ran into issues with
node-gyp-build for native modules in Parcel. Following the documentation and adding
pkgs.nodePackages.node-gyp-build to the
buildInputs did not help and the error NPM wants to give me is in
/build/.npm/_logs/xxx which I couldn’t figure out where it was to read since the build failed to produce the derivation. I also don’t see in this manner what
node2nix really gives me as it seems to be reimplementing what NPM does but is slower.
Trying to run NPM as a part of any of the build steps just ran into sandboxing issues I wasn’t understanding and again the build failed so the NPM logs are then gone(?). Do I want to have
node_modules and the relevant binaries as a part of my Nix store or is it not needed or valuable?
Previously I was just using Nix+Flakes to make dev shells and it’s been really nice and Flakes has made it fast and easy to upgrade. I’ve just been using NPM (or Yarn) and doing my work as I was previously using
asdf, but now I’d like to actually use
nix build but it hasn’t been to straightforward to me on how use Node packages and their binaries for this step. I didn’t have much luck searching other open source projects to understand either.
Any higher-level reading material on the subject or existing, Node-using projects to look at would be greatly appreciated.