Compare commits

..
2 Commits
Author SHA1 Message Date
Sascha König 1c46b2bcc5 n8n: 2.44.7 -> 2.45.5 2026-10-28 14:21:02 +01:00
Sascha König 68e22ee34b fix(n8n/update.sh): print diagnostics instead of dying silently
Under `set -euo pipefail` the pnpmDeps hash-extraction pipeline
(`grep -oE | grep -v | tail`) returns non-zero when the nix build output
contains no real sha256 — aborting the script BEFORE the ERROR
diagnostics could run. Symptom: update.sh exited 1 right after
'Computing pnpmDeps hash ...' with no message at all.

- Append `|| true` to the extraction pipeline so the empty-hash
  diagnostics are reachable again
- Same hardening for the GitHub release lookup (curl/jq) and
  nix-prefetch-url (now with an explicit guard + message)
- New diagnostic branch for ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY
  (newer upstream pnpm-lock serialisation → bump the pnpm major)
2026-10-28 14:12:07 +01:00
3 changed files with 69 additions and 35 deletions

No files matched your search

+42 -28
View File
@@ -5,53 +5,67 @@
# field. The old lockfile-integrity workaround is therefore obsolete and has # field. The old lockfile-integrity workaround is therefore obsolete and has
# been removed. # been removed.
# #
# n8n >= 2.37.0 demands pnpm >= 11.22.0 via `engines.pnpm`, but the pinned # n8n >= 2.45 switched to pnpm 12 (packageManager pnpm@12.4.2, engines.pnpm
# nixpkgs only ships pnpm_10 (10.34.5) and pnpm_11 (11.17.0) — both too old. # ">=12.4.2"), and its pnpm-lock.yaml now serialises pnpm-12 constructs
# pnpm enforces that gate for ITSELF regardless of `engine-strict`, so both # (packageManagerDependencies, `patch_hash` keys for patchedDependencies).
# fetchPnpmDeps and the main build die with ERR_PNPM_UNSUPPORTED_ENGINE # pnpm_11 dies on that lockfile with ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY
# before any hash mismatch is even reached. Additionally n8n's lockfile, # (no entry for 'lodash@4.18.1(patch_hash=...)'). The pinned nixpkgs ships
# while still declaring lockfileVersion '9.0', now serialises # pnpm_12 (12.9.0 >= 12.4.2), so fetch and build with pnpm_12. The
# patchedDependencies as plain `name@version: hash` scalars (no `path:` # engines.pnpm relaxation stays as a safety net for future upstream floor
# mapping), which pnpm 10 cannot parse (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH). # bumps ahead of nixpkgs — pnpm enforces that gate for ITSELF regardless of
# We therefore build with pnpm_11 + fetcherVersion 4 and relax the engine # engine-strict, so both fetchPnpmDeps and the main build would otherwise
# gate in package.json. Drop the sed once nixpkgs ships pnpm >= 11.22 and # die with ERR_PNPM_UNSUPPORTED_ENGINE before any hash mismatch is reached.
# this overlay's nixpkgs pin has caught up.
relaxPnpmEngine = '' relaxPnpmEngine = ''
sed -i -E 's/"pnpm": *"[^"]*"/"pnpm": "*"/' package.json 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 in
prev.n8n.overrideAttrs (finalAttrs: previousAttrs: { prev.n8n.overrideAttrs (finalAttrs: previousAttrs: {
version = "2.44.7"; version = "2.45.5";
src = prev.fetchFromGitHub { src = prev.fetchFromGitHub {
owner = "n8n-io"; owner = "n8n-io";
repo = "n8n"; repo = "n8n";
tag = "n8n@${finalAttrs.version}"; tag = "n8n@${finalAttrs.version}";
hash = "sha256-w4AjQjHDxD1fG21rt/apyElXu7hflVllWKVqrEHkR3I="; hash = "sha256-YPM8Hlgrll1I+yYj4Q2dWP8bF5nnLCF5VIMpl3N5Lzk=";
}; };
pnpmDeps = prev.fetchPnpmDeps { pnpmDeps = prev.fetchPnpmDeps {
inherit (finalAttrs) pname version src; inherit (finalAttrs) pname version src;
pnpm = prev.pnpm_11; pnpm = prev.pnpm_12;
fetcherVersion = 4; fetcherVersion = 4;
postPatch = relaxPnpmEngine; postPatch = relaxPnpmEngine + fixUpstreamLockfile;
hash = "sha256-vOJ+8OLpUtWvfy9QmR1X4dwOTY/GCpmM/M5HeB47BV0="; 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 # Swap the inherited pnpm (any major < 12) for pnpm_12: upstream n8n
# n8n calls pnpm directly during the build (install/build/prune) and pnpm 10 # calls pnpm directly during the build (install/build/prune) and older
# cannot parse the pnpm-11 lockfile. The top-level pnpmConfigHook stays as # majors cannot parse the pnpm-12 lockfile (see comment above). The
# is — it discovers the fetcher version from pnpmDeps' .fetcher-version. # top-level pnpmConfigHook stays as is — it discovers the fetcher version
# Match by pname/version, never by outPath: forcing prev.pnpm_10.outPath # from pnpmDeps' .fetcher-version. Match by pname/version, never by
# instantiates that derivation, and on nixpkgs pins where pnpm_10 is # outPath: forcing e.g. prev.pnpm_10.outPath instantiates that
# insecure-marked (e.g. nixos-26.05's pnpm 10.34.0) the comparison itself # derivation, and on nixpkgs pins where pnpm_10 is insecure-marked (e.g.
# throws "Refusing to evaluate" — even though the package is only being # nixos-26.05's pnpm 10.34.0) the comparison itself throws "Refusing to
# discarded here. pname/version are plain attrs and force nothing. # evaluate" — even though the package is only being discarded here.
# pname/version are plain attrs and force nothing.
nativeBuildInputs = builtins.map (x: nativeBuildInputs = builtins.map (x:
if (x.pname or null) == "pnpm" && prev.lib.versionOlder (x.version or "11") "11" if (x.pname or null) == "pnpm" && prev.lib.versionOlder (x.version or "12") "12"
then prev.pnpm_11 then prev.pnpm_12
else x) else x)
previousAttrs.nativeBuildInputs; previousAttrs.nativeBuildInputs;
+24 -4
View File
@@ -71,8 +71,11 @@ TAG_PREFIX="n8n@"
# ── 1. Latest stable release ─────────────────────────────────────────────── # ── 1. Latest stable release ───────────────────────────────────────────────
echo "Fetching latest stable release of $REPO ..." echo "Fetching latest stable release of $REPO ..."
# `|| true` keeps `set -euo pipefail` from killing the script inside the
# substitution on curl/jq failure (e.g. network down) — the empty-value
# check below then produces the actual error message.
LATEST_TAG=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" | LATEST_TAG=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" |
jq -r 'select(.prerelease == false) | .tag_name') jq -r 'select(.prerelease == false) | .tag_name' || true)
if [[ -z "$LATEST_TAG" ]]; then if [[ -z "$LATEST_TAG" ]]; then
echo "ERROR: No stable release found for $REPO" >&2 echo "ERROR: No stable release found for $REPO" >&2
@@ -114,8 +117,14 @@ sed -i "s|^\([[:space:]]*\)version = \"[^\"]*\";|\1version = \"$VERSION\";|" "$N
echo "==> Computing src hash ..." echo "==> Computing src hash ..."
SRC_URL="https://github.com/$REPO/archive/refs/tags/${TAG_PREFIX}${VERSION}.tar.gz" SRC_URL="https://github.com/$REPO/archive/refs/tags/${TAG_PREFIX}${VERSION}.tar.gz"
# `--name n8n-source` works around the `@` in the upstream tag name # `--name n8n-source` works around the `@` in the upstream tag name
# (nix-prefetch-url refuses filenames containing `@`). # (nix-prefetch-url refuses filenames containing `@`). `|| true` + guard so a
SRC_HASH=$(nix-prefetch-url --unpack --type sha256 --name n8n-source "$SRC_URL" 2>/dev/null) # prefetch failure (network, rate limit, vanished tag) prints an error instead
# of dying silently under `set -e` (stderr is discarded on purpose above).
SRC_HASH=$(nix-prefetch-url --unpack --type sha256 --name n8n-source "$SRC_URL" 2>/dev/null || true)
if [[ -z "$SRC_HASH" ]]; then
echo "ERROR: nix-prefetch-url could not fetch/hash $SRC_URL" >&2
exit 1
fi
SRC_SRI=$(nix hash convert --hash-algo sha256 --to sri "$SRC_HASH") SRC_SRI=$(nix hash convert --hash-algo sha256 --to sri "$SRC_HASH")
echo " src hash: $SRC_SRI" echo " src hash: $SRC_SRI"
@@ -155,10 +164,15 @@ BUILD_OUTPUT=$(nix build --impure --no-link --expr "$NIX_EXPR" 2>&1 || true)
# "specified"/"Expected" and the correct one as "got:"/"Got:". Different nix # "specified"/"Expected" and the correct one as "got:"/"Got:". Different nix
# versions label/capitalise differently, so filter out the sentinel and take # versions label/capitalise differently, so filter out the sentinel and take
# whatever real sha256 remains. # whatever real sha256 remains.
#
# The trailing `|| true` is load-bearing: with `set -euo pipefail` a pipeline
# like `grep -oE | grep -v | tail` returns non-zero when NO hash is present
# (grep finds nothing / grep -v filters everything), which used to abort the
# script right here — silently, before the diagnostics below could run.
PNPM_HASH=$(echo "$BUILD_OUTPUT" | PNPM_HASH=$(echo "$BUILD_OUTPUT" |
grep -oE 'sha256-[A-Za-z0-9+/=]+' | grep -oE 'sha256-[A-Za-z0-9+/=]+' |
grep -v 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' | grep -v 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' |
tail -1) tail -1 || true)
if [[ -z "$PNPM_HASH" ]]; then if [[ -z "$PNPM_HASH" ]]; then
echo "ERROR: could not extract a pnpmDeps hash from the build output." >&2 echo "ERROR: could not extract a pnpmDeps hash from the build output." >&2
@@ -170,6 +184,12 @@ if [[ -z "$PNPM_HASH" ]]; then
echo " Cause: the pinned pnpm cannot parse upstream's pnpm-lock.yaml" >&2 echo " Cause: the pinned pnpm cannot parse upstream's pnpm-lock.yaml" >&2
echo " anymore (lockfile serialisation changed across pnpm majors)." >&2 echo " anymore (lockfile serialisation changed across pnpm majors)." >&2
echo " Bump the pnpm major and fetcherVersion in $NIX_FILE." >&2 echo " Bump the pnpm major and fetcherVersion in $NIX_FILE." >&2
elif grep -q 'ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY' <<<"$BUILD_OUTPUT"; then
echo " Cause: the pinned pnpm cannot resolve upstream's pnpm-lock.yaml" >&2
echo " (upstream serialises newer lockfile constructs, e.g. patched-" >&2
echo " dependency patch_hash keys, that this pnpm major mishandles)." >&2
echo " Bump the pnpm major in $NIX_FILE (fetchPnpmDeps AND the" >&2
echo " nativeBuildInputs swap threshold)." >&2
else else
echo " This usually means fetchPnpmDeps failed for a reason OTHER than" >&2 echo " This usually means fetchPnpmDeps failed for a reason OTHER than" >&2
echo " a hash mismatch (e.g. a pnpm-lock patch in n8n.nix no longer applies," >&2 echo " a hash mismatch (e.g. a pnpm-lock patch in n8n.nix no longer applies," >&2
+3 -3
View File
@@ -15,9 +15,9 @@
modifiedPkgs = mkPkgs [self.overlays.modifications]; modifiedPkgs = mkPkgs [self.overlays.modifications];
defaultPkgs = mkPkgs [self.overlays.default]; defaultPkgs = mkPkgs [self.overlays.default];
expectedVersion = "2.44.7"; expectedVersion = "2.45.5";
expectedSrcHash = "sha256-w4AjQjHDxD1fG21rt/apyElXu7hflVllWKVqrEHkR3I="; expectedSrcHash = "sha256-YPM8Hlgrll1I+yYj4Q2dWP8bF5nnLCF5VIMpl3N5Lzk=";
expectedPnpmHash = "sha256-vOJ+8OLpUtWvfy9QmR1X4dwOTY/GCpmM/M5HeB47BV0="; expectedPnpmHash = "sha256-rZ3unYg6d0bAnU05e1ejGokIYKI1m7M97NiS+bqdZOE=";
expectedChangelog = "https://github.com/n8n-io/n8n/releases/tag/n8n@${expectedVersion}"; expectedChangelog = "https://github.com/n8n-io/n8n/releases/tag/n8n@${expectedVersion}";
expectedRootNodeModuleSymlinks = [ expectedRootNodeModuleSymlinks = [
"ln -s .pnpm/node_modules/sass-embedded node_modules/sass-embedded" "ln -s .pnpm/node_modules/sass-embedded node_modules/sass-embedded"