diff --git a/overlays/mods/n8n.nix b/overlays/mods/n8n.nix index f35a5bc..1438237 100644 --- a/overlays/mods/n8n.nix +++ b/overlays/mods/n8n.nix @@ -5,53 +5,67 @@ # 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. + # n8n >= 2.45 switched to pnpm 12 (packageManager pnpm@12.4.2, engines.pnpm + # ">=12.4.2"), and its pnpm-lock.yaml now serialises pnpm-12 constructs + # (packageManagerDependencies, `patch_hash` keys for patchedDependencies). + # pnpm_11 dies on that lockfile with ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY + # (no entry for 'lodash@4.18.1(patch_hash=...)'). The pinned nixpkgs ships + # pnpm_12 (12.9.0 >= 12.4.2), so fetch and build with pnpm_12. The + # engines.pnpm relaxation stays as a safety net for future upstream floor + # bumps ahead of nixpkgs — pnpm enforces that gate for ITSELF regardless of + # engine-strict, so both fetchPnpmDeps and the main build would otherwise + # die with ERR_PNPM_UNSUPPORTED_ENGINE before any hash mismatch is reached. relaxPnpmEngine = '' sed -i -E 's/"pnpm": *"[^"]*"/"pnpm": "*"/' package.json ''; + + # n8n@2.45.5 ships an internally inconsistent pnpm-lock.yaml: the + # patchedDependencies section declares lodash@4.18.1 with patch hash + # 0384abb0…, but two snapshot references (inside @malept/flatpak-bundler + # and electron-winstaller, both electron-builder dev deps) still point at + # the hash of a PREVIOUS version of patches/lodash@4.18.1.patch + # (81ead1b0…), for which no snapshot entry exists. pnpm 12.4.2 (upstream's + # packageManager) tolerates that, pnpm >= 12.9 refuses with + # ERR_PNPM_INCONSISTENT_PATCH_HASH. Rewrite the stale references to the + # declared hash — exactly what `pnpm install --no-frozen-lockfile` would + # converge to. The sed is a no-op once upstream regenerates the lockfile. + fixUpstreamLockfile = '' + sed -i 's/patch_hash=81ead1b07fc8efda87bd2724dbd876ab49f4a0aa03f96c3770060b2ea47d9e0b/patch_hash=0384abb0bf57b0811e09219dbce0b926741d818285ee77526ad4cb75a60b87a1/g' pnpm-lock.yaml + ''; in prev.n8n.overrideAttrs (finalAttrs: previousAttrs: { - version = "2.44.7"; + version = "2.45.5"; src = prev.fetchFromGitHub { owner = "n8n-io"; repo = "n8n"; tag = "n8n@${finalAttrs.version}"; - hash = "sha256-w4AjQjHDxD1fG21rt/apyElXu7hflVllWKVqrEHkR3I="; + hash = "sha256-YPM8Hlgrll1I+yYj4Q2dWP8bF5nnLCF5VIMpl3N5Lzk="; }; pnpmDeps = prev.fetchPnpmDeps { inherit (finalAttrs) pname version src; - pnpm = prev.pnpm_11; + pnpm = prev.pnpm_12; fetcherVersion = 4; - postPatch = relaxPnpmEngine; - hash = "sha256-vOJ+8OLpUtWvfy9QmR1X4dwOTY/GCpmM/M5HeB47BV0="; + postPatch = relaxPnpmEngine + fixUpstreamLockfile; + hash = "sha256-rZ3unYg6d0bAnU05e1ejGokIYKI1m7M97NiS+bqdZOE="; }; - postPatch = (previousAttrs.postPatch or "") + relaxPnpmEngine; + postPatch = (previousAttrs.postPatch or "") + relaxPnpmEngine + fixUpstreamLockfile; - # 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. - # Match by pname/version, never by outPath: forcing prev.pnpm_10.outPath - # instantiates that derivation, and on nixpkgs pins where pnpm_10 is - # insecure-marked (e.g. nixos-26.05's pnpm 10.34.0) the comparison itself - # throws "Refusing to evaluate" — even though the package is only being - # discarded here. pname/version are plain attrs and force nothing. + # Swap the inherited pnpm (any major < 12) for pnpm_12: upstream n8n + # calls pnpm directly during the build (install/build/prune) and older + # majors cannot parse the pnpm-12 lockfile (see comment above). The + # top-level pnpmConfigHook stays as is — it discovers the fetcher version + # from pnpmDeps' .fetcher-version. Match by pname/version, never by + # outPath: forcing e.g. prev.pnpm_10.outPath instantiates that + # derivation, and on nixpkgs pins where pnpm_10 is insecure-marked (e.g. + # nixos-26.05's pnpm 10.34.0) the comparison itself throws "Refusing to + # evaluate" — even though the package is only being discarded here. + # pname/version are plain attrs and force nothing. nativeBuildInputs = builtins.map (x: - if (x.pname or null) == "pnpm" && prev.lib.versionOlder (x.version or "11") "11" - then prev.pnpm_11 + if (x.pname or null) == "pnpm" && prev.lib.versionOlder (x.version or "12") "12" + then prev.pnpm_12 else x) previousAttrs.nativeBuildInputs; diff --git a/tests/n8n-overlay-test.nix b/tests/n8n-overlay-test.nix index 22ed249..8ee7c68 100644 --- a/tests/n8n-overlay-test.nix +++ b/tests/n8n-overlay-test.nix @@ -15,9 +15,9 @@ modifiedPkgs = mkPkgs [self.overlays.modifications]; defaultPkgs = mkPkgs [self.overlays.default]; - expectedVersion = "2.44.7"; - expectedSrcHash = "sha256-w4AjQjHDxD1fG21rt/apyElXu7hflVllWKVqrEHkR3I="; - expectedPnpmHash = "sha256-vOJ+8OLpUtWvfy9QmR1X4dwOTY/GCpmM/M5HeB47BV0="; + expectedVersion = "2.45.5"; + expectedSrcHash = "sha256-YPM8Hlgrll1I+yYj4Q2dWP8bF5nnLCF5VIMpl3N5Lzk="; + expectedPnpmHash = "sha256-rZ3unYg6d0bAnU05e1ejGokIYKI1m7M97NiS+bqdZOE="; expectedChangelog = "https://github.com/n8n-io/n8n/releases/tag/n8n@${expectedVersion}"; expectedRootNodeModuleSymlinks = [ "ln -s .pnpm/node_modules/sass-embedded node_modules/sass-embedded"