packages/qnode/npm-cli.nix
Rehost a pure-JS npm CLI on qnode. The package is built natively (buildPackages: npm, bundlers and node run at build time only); its lib/node_modules is platform-independent JavaScript. Only the launcher changes, from node to qnode.
λlib, runCommand, makeWrapper, qnode
λpackage, bins
runCommand"${package.pname}-${package.version}"
The native build, e.g. buildPackages.bibtex-tidy.
Executable name -> script path relative to lib/node_modules.
mkdir -p $out/lib $out/bin
cp -r ${package}/lib/node_modules $out/lib/
chmod -R u+w $out/lib
# Native node shebangs would keep the build platform's node in the
# runtime closure; qnode ignores the shebang line.
grep -rlZ '^#!/nix/store/[^/]*-nodejs' $out/lib | \
xargs -0 -r sed -i '1s|^#!/nix/store/[^ ]*|#!/usr/bin/env node|'