From 5aaeafbe2603df195938edaa91c2a68739eb499d Mon Sep 17 00:00:00 2001 From: Yt Date: Thu, 9 Nov 2023 16:19:24 +0000 Subject: [PATCH] buildNpmPackage: make nodejs overridable (#265171) * buildNpmPackage: allow nodejs to be passed as argument * Update doc/languages-frameworks/javascript.section.md Co-authored-by: Lily Foster --------- Co-authored-by: Lily Foster --- doc/languages-frameworks/javascript.section.md | 1 + pkgs/build-support/node/build-npm-package/default.nix | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index f35fd83cc594..79cb09572503 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -209,6 +209,7 @@ In the default `installPhase` set by `buildNpmPackage`, it uses `npm pack --json * `npmPackFlags`: Flags to pass to `npm pack`. * `npmPruneFlags`: Flags to pass to `npm prune`. Defaults to the value of `npmInstallFlags`. * `makeWrapperArgs`: Flags to pass to `makeWrapper`, added to executable calling the generated `.js` with `node` as an interpreter. These scripts are defined in `package.json`. +* `nodejs`: The `nodejs` package to build against, using the corresponding `npm` shipped with that version of `node`. Defaults to `pkgs.nodejs`. #### prefetch-npm-deps {#javascript-buildNpmPackage-prefetch-npm-deps} diff --git a/pkgs/build-support/node/build-npm-package/default.nix b/pkgs/build-support/node/build-npm-package/default.nix index 7cfc0e9f9c0a..9babc7ae6287 100644 --- a/pkgs/build-support/node/build-npm-package/default.nix +++ b/pkgs/build-support/node/build-npm-package/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchNpmDeps, buildPackages, nodejs }: +{ lib, stdenv, fetchNpmDeps, buildPackages, nodejs } @ topLevelArgs: { name ? "${args.pname}-${args.version}" , src ? null @@ -34,6 +34,7 @@ , npmPruneFlags ? npmInstallFlags # Value for npm `--workspace` flag and directory in which the files to be installed are found. , npmWorkspace ? null +, nodejs ? topLevelArgs.nodejs , ... } @ args: