buildNpmPackage: push npm_config_* options into npmHooks.npmConfigHook

these options affect npm generally, and aren't specific to our
`buildNpmPackage`. pushing these options into the `npmConfigHook` (which
is used by `buildNpmPackage`, among others) makes them available to more
packages, especially to enable cross compilation.
This commit is contained in:
Colin
2025-07-07 03:08:13 +00:00
parent 8199f6b551
commit faeab3c841
3 changed files with 5 additions and 5 deletions
@@ -103,11 +103,6 @@ lib.extendMkDerivation {
# Stripping takes way too long with the amount of files required by a typical Node.js project.
dontStrip = args.dontStrip or true;
env = {
npm_config_arch = stdenv.hostPlatform.node.arch;
npm_config_platform = stdenv.hostPlatform.node.platform;
} // (args.env or { });
meta = (args.meta or { }) // {
platforms = args.meta.platforms or nodejs.meta.platforms;
};
@@ -1,6 +1,7 @@
{
lib,
srcOnly,
stdenv,
makeSetupHook,
makeWrapper,
nodejs,
@@ -18,6 +19,8 @@
substitutions = {
nodeSrc = srcOnly nodejs;
nodeGyp = "${nodejs}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js";
npmArch = stdenv.targetPlatform.node.arch;
npmPlatform = stdenv.targetPlatform.node.platform;
# Specify `diff`, `jq`, and `prefetch-npm-deps` by abspath to ensure that the user's build
# inputs do not cause us to find the wrong binaries.
@@ -16,6 +16,8 @@ npmConfigHook() {
export HOME="$TMPDIR"
export npm_config_nodedir="@nodeSrc@"
export npm_config_node_gyp="@nodeGyp@"
export npm_config_arch="@npmArch@"
export npm_config_platform="@npmPlatform@"
if [ -z "${npmDeps-}" ]; then
echo