Merge pull request #202912 from NixOS/backport-201731-to-release-22.11

[Backport release-22.11] fetchNpmDeps: allow package-json.lock symlinks
This commit is contained in:
figsoda
2022-11-25 16:15:30 -05:00
committed by GitHub
3 changed files with 6 additions and 4 deletions

View File

@@ -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;
};

View File

@@ -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"

View File

@@ -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