From df5f93e75d76c91c435c3055ee39d7b88759a08e Mon Sep 17 00:00:00 2001 From: ilkecan Date: Sat, 25 Sep 2021 23:34:30 +0300 Subject: [PATCH 1/2] Parameterize the command that install dependencies --- API.md | 1 + internal.nix | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/API.md b/API.md index ea50b97..cc12c54 100644 --- a/API.md +++ b/API.md @@ -14,6 +14,7 @@ The `node_modules` function takes an attribute set with the following attributes - **packageJson** *(default `src+"/package.json"`)*: Path to `package.json` - **packageLockJson** *(default `src+"/package-lock.json"`)*: Path to `package-lock.json` - **nodejs** *(default `nixpkgs.nodejs`, which is the Active LTS version)*: Node.js derivation to use +- **npmCmd** *(default `npm install --offline`)*: npm command to install dependencies - **preInstallLinks** *(default `{}`)*: Map of symlinks to create inside npm dependencies in the `node_modules` output (See [Concepts](#concepts) for details). - **githubSourceHashMap** *(default `{}`)*: Dependency hashes for evaluation in restricted mode (See [Concepts](#concepts) for details). diff --git a/internal.nix b/internal.nix index 0d3754f..7fdaac0 100644 --- a/internal.nix +++ b/internal.nix @@ -290,6 +290,7 @@ rec { , buildInputs ? [ ] , nativeBuildInputs ? [ ] , nodejs ? default_nodejs + , npmCmd ? "npm install --offline" , preBuild ? "" , postBuild ? "" , preInstallLinks ? { } # set that describes which files should be linked in a specific packages folder @@ -373,7 +374,7 @@ rec { declare -pf > $TMP/preinstall-env ln -s ${preinstall_node_modules}/node_modules/.hooks/prepare node_modules/.hooks/preinstall export HOME=. - npm install --offline --nodedir=${nodeSource nodejs} + ${npmCmd} --nodedir=${nodeSource nodejs} test -d node_modules/.bin && patchShebangs node_modules/.bin rm -rf node_modules/.hooks runHook postBuild From 25b0bc2514b28555914dec3c51e957726809396a Mon Sep 17 00:00:00 2001 From: ilkecan Date: Sun, 26 Sep 2021 14:10:28 +0300 Subject: [PATCH 2/2] Replace npmCmd parameter with installCommands --- API.md | 2 +- internal.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/API.md b/API.md index cc12c54..7f11f6b 100644 --- a/API.md +++ b/API.md @@ -14,7 +14,7 @@ The `node_modules` function takes an attribute set with the following attributes - **packageJson** *(default `src+"/package.json"`)*: Path to `package.json` - **packageLockJson** *(default `src+"/package-lock.json"`)*: Path to `package-lock.json` - **nodejs** *(default `nixpkgs.nodejs`, which is the Active LTS version)*: Node.js derivation to use -- **npmCmd** *(default `npm install --offline`)*: npm command to install dependencies +- **installCommands** *(default `[ "npm install --offline --nodedir=${nodeSource nodejs}" ]`)*: List of commands to install dependencies. - **preInstallLinks** *(default `{}`)*: Map of symlinks to create inside npm dependencies in the `node_modules` output (See [Concepts](#concepts) for details). - **githubSourceHashMap** *(default `{}`)*: Dependency hashes for evaluation in restricted mode (See [Concepts](#concepts) for details). diff --git a/internal.nix b/internal.nix index 7fdaac0..c33dd05 100644 --- a/internal.nix +++ b/internal.nix @@ -290,7 +290,7 @@ rec { , buildInputs ? [ ] , nativeBuildInputs ? [ ] , nodejs ? default_nodejs - , npmCmd ? "npm install --offline" + , installCommands ? [ "npm install --offline --nodedir=${nodeSource nodejs}" ] , preBuild ? "" , postBuild ? "" , preInstallLinks ? { } # set that describes which files should be linked in a specific packages folder @@ -374,7 +374,7 @@ rec { declare -pf > $TMP/preinstall-env ln -s ${preinstall_node_modules}/node_modules/.hooks/prepare node_modules/.hooks/preinstall export HOME=. - ${npmCmd} --nodedir=${nodeSource nodejs} + ${lib.concatStringsSep "\n" installCommands} test -d node_modules/.bin && patchShebangs node_modules/.bin rm -rf node_modules/.hooks runHook postBuild