about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLily Foster <lily@lily.flowers>2023-09-13 21:37:29 -0400
committerWinter <winter@winter.cafe>2024-04-17 14:47:16 -0500
commit4a6511fb9820ee8cfe172a790b8ac22fb96e698e (patch)
treec64c5298ebc9102b973b962eda5d2bd3f08002a5
parentd94833deff1700f6cde7a366464abee650cb25c0 (diff)
nodejs: make buildNpmPackage git dep lockfile fixup fail gracefully when no lockfile exists and git deps forced
Some git dependencies with install scripts might genuinely have no
declared dependencies of their own and thus theoretically should be able
to build without a lockfile. Making the lockfile fixup fail gracefully
instead of fatally when `forceGitDeps = true` is on allows those
packages to work.
-rw-r--r--pkgs/development/web/nodejs/node-npm-build-npm-package-logic.patch4
1 files changed, 2 insertions, 2 deletions
diff --git a/pkgs/development/web/nodejs/node-npm-build-npm-package-logic.patch b/pkgs/development/web/nodejs/node-npm-build-npm-package-logic.patch
index a9ac6b0589efc..a24ab07a3d804 100644
--- a/pkgs/development/web/nodejs/node-npm-build-npm-package-logic.patch
+++ b/pkgs/development/web/nodejs/node-npm-build-npm-package-logic.patch
@@ -49,7 +49,7 @@ index 1fa8b1f96..a026bb50d 100644
 +      if (process.env['NIX_NODEJS_BUILDNPMPACKAGE']) {
 +        const spawn = require('@npmcli/promise-spawn')
 +
-+        const npmWithNixFlags = (args, cmd) => spawn('bash', ['-c', 'npm ' + args + ` $npm${cmd}Flags "$\{npm${cmd}FlagsArray[@]}" $npmFlags "$\{npmFlagsArray[@]}"`], { cwd: dir, env: { ...process.env, _PACOTE_NO_PREPARE_: noPrepare.join('\n') } }, { message: `\`npm ${args}\` failed` })
++        const npmWithNixFlags = (args, cmd) => spawn('bash', ['-c', 'npm ' + args + ` $npm${cmd}Flags "$\{npm${cmd}FlagsArray[@]}" $npmFlags "$\{npmFlagsArray[@]}" || [ -n "$forceGitDeps" ]`], { cwd: dir, env: { ...process.env, _PACOTE_NO_PREPARE_: noPrepare.join('\n') } }, { message: `\`npm ${args}\` failed` })
 +        const patchShebangs = () => spawn('bash', ['-c', 'source $stdenv/setup; patchShebangs node_modules'], { cwd: dir })
 +
 +        // the DirFetcher will do its own preparation to run the prepare scripts
@@ -57,7 +57,7 @@ index 1fa8b1f96..a026bb50d 100644
 +        //
 +        // We ignore this.npmConfig to maintain an environment that's as close
 +        // to the rest of the build as possible.
-+        return spawn('bash', ['-c', '$prefetchNpmDeps --fixup-lockfile package-lock.json'], { cwd: dir })
++        return spawn('bash', ['-c', '$prefetchNpmDeps --fixup-lockfile package-lock.json || [ -n "$forceGitDeps" ]'], { cwd: dir })
 +        .then(() => npmWithNixFlags('ci --ignore-scripts', 'Install'))
 +        .then(patchShebangs)
 +        .then(() => npmWithNixFlags('rebuild', 'Rebuild'))