fix(n8n): re-link peer dependencies dropped by pnpm 12 prune --prod

This commit is contained in:
Sascha König committed 2026-10-28 19:38:17 +01:00
1 parent 4a047cb3be
commit 1fa50fe47a
2 files changed
+62 -1

No files matched your search

+16
View File
@@ -23,6 +23,13 @@
"ln -s .pnpm/node_modules/sass-embedded node_modules/sass-embedded"
"ln -s .pnpm/node_modules/sqlite3 node_modules/sqlite3"
];
# pnpm 12: prune must run offline without the minimumReleaseAge registry
# check, and peers it drops must be re-linked from the hoisted directory.
expectedPreInstallSnippets = [
"pnpm --ignore-scripts --offline --config.minimum-release-age=0 prune --prod -w"
"Re-linking peer dependencies dropped by pnpm prune"
"node_modules/.pnpm/node_modules"
];
checkN8nOverride = overlayName: package:
if package.version != expectedVersion
@@ -44,6 +51,13 @@
if !(pkgs.lib.all (symlink: pkgs.lib.hasInfix symlink (package.preBuild or "")) expectedRootNodeModuleSymlinks)
then throw "${overlayName} n8n preBuild should create root node_modules symlinks required by the upstream buildPhase"
else "ok";
checkPreInstallPnpm12 = overlayName: package:
if !(pkgs.lib.all (snippet: pkgs.lib.hasInfix snippet (package.preInstall or "")) expectedPreInstallSnippets)
then throw "${overlayName} n8n preInstall should prune offline with pnpm 12 and re-link pruned peer dependencies"
else if pkgs.lib.hasInfix "pnpm --ignore-scripts prune --prod -w" (package.preInstall or "")
then throw "${overlayName} n8n preInstall still contains the unmodified upstream prune command"
else "ok";
in
pkgs.runCommand "n8n-overlay-test" {
n8nOverlayFile =
@@ -60,6 +74,8 @@ in
defaultOverlayBuildPhase = checkBuildPhaseInherited "overlays.default" defaultPkgs.n8n;
modificationsOverlayRootNodeModuleSymlinks = checkRootNodeModuleSymlinks "overlays.modifications" modifiedPkgs.n8n;
defaultOverlayRootNodeModuleSymlinks = checkRootNodeModuleSymlinks "overlays.default" defaultPkgs.n8n;
modificationsOverlayPreInstall = checkPreInstallPnpm12 "overlays.modifications" modifiedPkgs.n8n;
defaultOverlayPreInstall = checkPreInstallPnpm12 "overlays.default" defaultPkgs.n8n;
} ''
touch $out
''