n8n: 2.36.8 -> 2.37.9, migrate to pnpm 11, harden update.sh

n8n >= 2.37.0 demands pnpm >= 11.22.0 via engines.pnpm and serialises
patchedDependencies as plain scalars in pnpm-lock.yaml (same
lockfileVersion '9.0'), which pnpm 10 cannot install. The pinned nixpkgs
only ships pnpm_11 11.17.0, so:

- build with pnpm_11 + fetcherVersion 4 and relax the engines.pnpm gate
  in package.json (relaxPnpmEngine) for both fetchPnpmDeps and the main
  build; swap pnpm_10 -> pnpm_11 in nativeBuildInputs
- drop the workaround once nixpkgs ships pnpm >= 11.22

update.sh: detect ERR_PNPM_UNSUPPORTED_ENGINE /
ERR_PNPM_LOCKFILE_CONFIG_MISMATCH with actionable hints, sync
tests/n8n-overlay-test.nix expectations (checks were stale at 2.32.6),
guard against leftover fake-hash sentinels, and run from the repo root
so the relative nix --expr paths resolve.

Verified: n8n-overlay check green, full n8n 2.37.9 build green.
This commit is contained in:
2026-09-04 08:04:34 +02:00
parent 8f2d1beba3
commit c22cb5f3a7
3 changed files with 117 additions and 26 deletions
+33 -5
View File
@@ -4,24 +4,52 @@
# regular npm package `@e965/xlsx@0.20.3`, which already carries an integrity
# field. The old lockfile-integrity workaround is therefore obsolete and has
# been removed.
#
# n8n >= 2.37.0 demands pnpm >= 11.22.0 via `engines.pnpm`, but the pinned
# nixpkgs only ships pnpm_10 (10.34.5) and pnpm_11 (11.17.0) — both too old.
# pnpm enforces that gate for ITSELF regardless of `engine-strict`, so both
# fetchPnpmDeps and the main build die with ERR_PNPM_UNSUPPORTED_ENGINE
# before any hash mismatch is even reached. Additionally n8n's lockfile,
# while still declaring lockfileVersion '9.0', now serialises
# patchedDependencies as plain `name@version: hash` scalars (no `path:`
# mapping), which pnpm 10 cannot parse (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH).
# We therefore build with pnpm_11 + fetcherVersion 4 and relax the engine
# gate in package.json. Drop the sed once nixpkgs ships pnpm >= 11.22 and
# this overlay's nixpkgs pin has caught up.
relaxPnpmEngine = ''
sed -i -E 's/"pnpm": *"[^"]*"/"pnpm": "*"/' package.json
'';
in
prev.n8n.overrideAttrs (finalAttrs: previousAttrs: {
version = "2.36.8";
version = "2.37.9";
src = prev.fetchFromGitHub {
owner = "n8n-io";
repo = "n8n";
tag = "n8n@${finalAttrs.version}";
hash = "sha256-2id5kyrISnYdhM/LPkyjZS5WrjeWHis/hu2zAMKY4wA=";
hash = "sha256-DFoXCtn+rM69ISKVV2aet8LfGCOsN29yuyYOpz0f71U=";
};
pnpmDeps = prev.fetchPnpmDeps {
inherit (finalAttrs) pname version src;
pnpm = prev.pnpm_10;
fetcherVersion = 3;
hash = "sha256-KCVNWw2at/282bwqYi9VHC6fSF7foQkPHme3M+CfmiE=";
pnpm = prev.pnpm_11;
fetcherVersion = 4;
postPatch = relaxPnpmEngine;
hash = "sha256-4SFl0JD4iQc4tQFtJvNWkYCVyT6sj7+id/BrJEaTl8E=";
};
postPatch = (previousAttrs.postPatch or "") + relaxPnpmEngine;
# Swap pnpm_10 -> pnpm_11 from the inherited nativeBuildInputs: upstream
# n8n calls pnpm directly during the build (install/build/prune) and pnpm 10
# cannot parse the pnpm-11 lockfile. The top-level pnpmConfigHook stays as
# is — it discovers the fetcher version from pnpmDeps' .fetcher-version.
nativeBuildInputs = builtins.map (x:
if (x.outPath or null) == prev.pnpm_10.outPath
then prev.pnpm_11
else x)
previousAttrs.nativeBuildInputs;
preBuild =
(previousAttrs.preBuild or "")
+ ''