Moving away from an OS like Arch where packages are mostly available, how does one deal with a missing dev dependency like libpng-dev?

I have an issue with a Node package dependency - pngquant-bin. It's relying on libpng-dev package to build pngquant-bin. libpng & pngquant are both available in Nixpkgs, but it's trying to find libpng-dev.

What is the best solution in this case? e.g. setting up an overlay, creating the package from source...


Using libpng-config --cflag shows where the development headers are. I'd assume I can somehow direct the NPM package to these headers to build the pngquant-bin binary.

I have logged an issue on GitHub that provides more detail: https://github.com/svanderburg/node2nix/issues/123

Disclaimer: I'm new to NixOS - coming from Arch. I appreciate any advice, loving NixOS!


It appears that the libpng package has multiple outputs, one of which is the dev build. On my macOS machine:

brocking@station1:~/dev > nix-env -qasA nixpkgs.libpng.dev
-PS  libpng-apng-1.6.34

There's a chapter in the manual for the nixpkgs collection that covers this. IIRC the nixpkgs collection has included multiple outputs for the last few major releases and I believe that many packages are built in this manner now.

PS there's also a section in the nixpkgs manual that covers node.js packages which is probably worth taking a look at also.

I've had a quick look at the GitHub issue that you've opened and you definitely seem to be on the right track, but unfortunately I am not familiar enough with either node.js or node2nix to be able to see exactly what the problem is.

However, one general point I can make though is that whenever you are trying to package something with Nix and you get an error such as you've experienced below then it almost always means that either or both 1. you need to tell nix how it can get hold of a dependency (libpng-dev in this case) and 2. you need to make sure that the nix expression that you are trying to build somehow includes a reference to 1. (often that is via a buildInputs nix attribute, although that depends very much what build system you are using), in your case I am guessing that it might be as an argument to the pngquant expression in the default.nix file generated by node2nix, although as I said it is quite unfamiliar for me so I may be quite wrong about that.

ℹ compiling from source ✔ pngquant pre-build test passed successfully ✖ RequestError: pngquant failed to build, make sure that libpng-dev is installed

You may find some more and faster help in the chat on the #nixos IRC channel, people on there are very helpful and I have found a lot of knowledge on there previously.

One last remark, the great strength of Nix is its purity - you have to tell it exactly where to find everything, and that can be a little daunting at first. However once you get your head around that then the purity is something you can really appreciate.

  • I'm going to mark your answer as correct, because It's probably send my on the right path, but the issue still persists - here's the GitHub issue I submitted: github.com/svanderburg/node2nix/issues/123 – YodaScholtz Dec 13 '18 at 12:13
  • 1
    I've added a few extra comments in my answer about the GitHub issue you've raised. I'm afraid I'm not familiar enough to be able to see exactly what the problem is but I hope they are of some help at least. – brocking Dec 13 '18 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.