node2nix icon indicating copy to clipboard operation
node2nix copied to clipboard

Patch shebangs in dependency binaries

Open thomasjm opened this issue 4 years ago • 3 comments

I needed to do this so that a call to node-gyp-build would work in one of my dependencies.

Sometimes a dependency comes with an executable script, which ultimately gets symlinked into node_modules/.bin. The existing patchShebangs call at the beginning of prepareAndInvokeNPM doesn't always catch these, because they don't always have the executable bit set. As a result, you get a failure in the Nix build because /usr/bin/env node doesn't exist.

So, this PR uses jq to traverse the bin field of package.json, turning these files executable and patching them as necessary.

This PR also exposes the preRebuild hook for buildNodeDependencies, and by extension for the shell attribute. I think this will resolve #226.

thomasjm avatar Oct 14 '21 02:10 thomasjm

I've implemented my own implementation that does not rely on jq or examining the package.json config. I think this should work because references in bin/ always resolve to paths installed in the same output Nix store path.

I'm still validating whether this does not introduce new problems.

svanderburg avatar Nov 14 '21 14:11 svanderburg

I was able to package my npm-based piece of software only with this patch. Would be great to have this merged!

pmiddend avatar Nov 21 '21 11:11 pmiddend

Just wanted to check @svanderburg, is this fixed now? I'll close the PR if so.

thomasjm avatar Apr 07 '23 20:04 thomasjm