Files
nixpkgs/tests/n8n-overlay-test.nix
m3tam3re 8d9b0cf742 n8n: 2.31.6 → 2.32.6, drop obsolete xlsx lockfile workaround, harden update.sh
n8n 2.32 replaced the sheetjs-CDN xlsx@0.20.2 tarball (which lacked an
integrity checksum and had to be patched into pnpm-lock.yaml) with the
regular npm package @e965/xlsx@0.20.3, which already carries an integrity
field. The patchXlsxLockfile workaround is therefore obsolete and actively
harmful: substituteInPlace --replace-fail no longer matches, making
fetchPnpmDeps fail with a build error (not a hash mismatch), which left the
fake-hash sentinel behind in n8n.nix on update.

- overlays/mods/n8n.nix: remove xlsx workaround; bump to 2.32.6 with real
  src (sha256-wWm6...) and pnpmDeps (sha256-QzUJCF+...) hashes.
- tests/n8n-overlay-test.nix: update expectations to 2.32.6; drop the
  obsolete checkXlsxIntegrityPatch.
- overlays/mods/update.sh: use a literal SRI sentinel instead of lib.fakeHash
  (lib is not in scope inside the {prev}: overlay); add a snapshot-based EXIT
  trap that restores n8n.nix on any failure (error/SIGINT/SIGTERM/killed
  build) while preserving pre-existing working-tree edits; surface a clearer
  message when fetchPnpmDeps fails for a non-hash reason.
2026-07-30 08:09:36 +02:00

66 lines
2.9 KiB
Nix

{
pkgs,
inputs,
self,
}: let
localPackages = import ../pkgs {inherit pkgs inputs;};
mkPkgs = overlays:
import inputs.nixpkgs {
system = pkgs.stdenv.hostPlatform.system;
config.allowUnfree = true;
inherit overlays;
};
upstreamPkgs = mkPkgs [];
modifiedPkgs = mkPkgs [self.overlays.modifications];
defaultPkgs = mkPkgs [self.overlays.default];
expectedVersion = "2.32.6";
expectedSrcHash = "sha256-wWm6vGyJ2I2SBU38gRGaZG2FR5FBxH6V/sWQwn5B4Ac=";
expectedPnpmHash = "sha256-QzUJCF+VIku9/HrmiUR9FNCU3MlYtyKOILZjFNXvN8U=";
expectedChangelog = "https://github.com/n8n-io/n8n/releases/tag/n8n@${expectedVersion}";
expectedRootNodeModuleSymlinks = [
"ln -s .pnpm/node_modules/sass-embedded node_modules/sass-embedded"
"ln -s .pnpm/node_modules/sqlite3 node_modules/sqlite3"
];
checkN8nOverride = overlayName: package:
if package.version != expectedVersion
then throw "${overlayName} n8n version is ${package.version}, expected ${expectedVersion}"
else if package.src.outputHash != expectedSrcHash
then throw "${overlayName} n8n src hash is ${package.src.outputHash}, expected ${expectedSrcHash}"
else if package.pnpmDeps.outputHash != expectedPnpmHash
then throw "${overlayName} n8n pnpmDeps hash is ${package.pnpmDeps.outputHash}, expected ${expectedPnpmHash}"
else if package.meta.changelog != expectedChangelog
then throw "${overlayName} n8n changelog is ${package.meta.changelog}, expected ${expectedChangelog}"
else "ok";
checkBuildPhaseInherited = overlayName: package:
if package.buildPhase != upstreamPkgs.n8n.buildPhase
then throw "${overlayName} n8n buildPhase should be inherited from upstream nixpkgs"
else "ok";
checkRootNodeModuleSymlinks = overlayName: package:
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";
in
pkgs.runCommand "n8n-overlay-test" {
n8nOverlayFile =
if builtins.pathExists ../overlays/mods/n8n.nix
then "ok"
else throw "n8n overlay override must live in overlays/mods/n8n.nix";
localN8nAbsent =
if localPackages ? n8n
then throw "pkgs/default.nix must not export a local n8n package"
else "ok";
modificationsOverlayN8n = checkN8nOverride "overlays.modifications" modifiedPkgs.n8n;
defaultOverlayN8n = checkN8nOverride "overlays.default" defaultPkgs.n8n;
modificationsOverlayBuildPhase = checkBuildPhaseInherited "overlays.modifications" modifiedPkgs.n8n;
defaultOverlayBuildPhase = checkBuildPhaseInherited "overlays.default" defaultPkgs.n8n;
modificationsOverlayRootNodeModuleSymlinks = checkRootNodeModuleSymlinks "overlays.modifications" modifiedPkgs.n8n;
defaultOverlayRootNodeModuleSymlinks = checkRootNodeModuleSymlinks "overlays.default" defaultPkgs.n8n;
} ''
touch $out
''