From 4bf8e82a6d01bfa8e181bd60e48d88c46ca3172e Mon Sep 17 00:00:00 2001 From: Sandro Date: Fri, 18 Nov 2022 06:51:26 +0100 Subject: [PATCH 1/3] fetchNpmDeps: allow package-json.lock symlinks, update hint (cherry picked from commit 8784305f8d01fe34d044f505e96abd0ed3d4e77c) --- pkgs/build-support/node/fetch-npm-deps/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/node/fetch-npm-deps/default.nix b/pkgs/build-support/node/fetch-npm-deps/default.nix index 7d5ea7cbfbe8..9e21836e5834 100644 --- a/pkgs/build-support/node/fetch-npm-deps/default.nix +++ b/pkgs/build-support/node/fetch-npm-deps/default.nix @@ -140,14 +140,14 @@ buildPhase = '' runHook preBuild - if [[ ! -f package-lock.json ]]; then + if [[ ! -e package-lock.json ]]; then echo echo "ERROR: The package-lock.json file does not exist!" echo echo "package-lock.json is required to make sure that npmDepsHash doesn't change" echo "when packages are updated on npm." echo - echo "Hint: You can use the patches attribute to add a package-lock.json manually to the build." + echo "Hint: You can copy a vendored package-lock.json file via postPatch." echo exit 1 From 80735a19be277ca304114bb272cb2fca6d75e626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 19 Nov 2022 06:31:18 +0100 Subject: [PATCH 2/3] buildNpmPackage: forward pre/postPatch to fetchNpmDeps (cherry picked from commit 4698fe1f970feffa8ad730d78a2f9dd972a432e8) --- pkgs/build-support/node/build-npm-package/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/node/build-npm-package/default.nix b/pkgs/build-support/node/build-npm-package/default.nix index 5ab86996e56b..26cc678c571e 100644 --- a/pkgs/build-support/node/build-npm-package/default.nix +++ b/pkgs/build-support/node/build-npm-package/default.nix @@ -4,7 +4,9 @@ , src ? null , srcs ? null , sourceRoot ? null +, prePatch ? "" , patches ? [ ] +, postPatch ? "" , nativeBuildInputs ? [ ] , buildInputs ? [ ] # The output hash of the dependencies for this project. @@ -30,7 +32,7 @@ let npmDeps = fetchNpmDeps { - inherit src srcs sourceRoot patches; + inherit src srcs sourceRoot prePatch patches postPatch; name = "${name}-npm-deps"; hash = npmDepsHash; }; From 1ec4725e4f84144fdb73d0b021768a5d9f6d514f Mon Sep 17 00:00:00 2001 From: Winter Date: Wed, 23 Nov 2022 21:11:45 -0500 Subject: [PATCH 3/3] npmHooks.npmInstallHook: pass --no-save to prune (cherry picked from commit 713040028b9f1fe551a10b8d86abbe68f301e39f) --- .../node/build-npm-package/hooks/npm-install-hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh b/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh index c3983e289568..59ea2da993d8 100644 --- a/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh +++ b/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh @@ -27,7 +27,7 @@ npmInstallHook() { local -r nodeModulesPath="$packageOut/node_modules" if [ ! -d "$nodeModulesPath" ]; then - npm prune --omit dev $npmInstallFlags "${npmInstallFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}" + npm prune --omit dev --no-save $npmInstallFlags "${npmInstallFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}" find node_modules -maxdepth 1 -type d -empty -delete cp -r node_modules "$nodeModulesPath"