Question: who are `buildNpmPackage`'s primary users?

I’m adventuring packaging a node.js application.
I’m currently trying nixpkgs.buildNpmPackage to do this. Given the number of bugs, and difficulties, I’ve feeling like I may not be a target use case.
The application is managed using npm and most of its dependencies are not in nixpkgs.

Do you know who the primary consumers of buildNpmPackage are?

Or if you use npm and nix together, how do you mix both worlds successfully?

notes on my experience thus far

  • I’m packaging node-canvas: https://github.com/Automattic/node-canvas/. I hope to upstream this effort to nixpkgs.
  • buildNpmPackage assumes dependencies will have a package-lock.json. I need to document the bug but found one code path where this line failed.
  • buildNpmPackage requires one’s package-lock.json to have been generated with correct resolved and integrity keys. As a naive developer, this tripped me up for a few days. Unfortunately this is an upstream issue: https://github.com/npm/cli/issues/4263

Every single nodePackage packaged in nixpkgs: NixOS Search

It’s unfortunately one of the best tools we have for this purpose. I wouldn’t per-se call issues you run into with it “bugs”, most of it is just npm really not fitting into the nix build model (npm gives free-reign to build script authors, to the point that I’ve seen projects download pre-compiled shared libraries from public dropbox folders), especially when you start playing with stuff like electron.

If you don’t need to contribute your package to nixpkgs, I’ve had a rather decent experience with dream2nix. YMMV depending on the project you build though.

1 Like