Files
nixpkgs/tests/n8n-overlay-test.nix
T

78 lines
3.5 KiB
Nix
Raw Normal View History

{
pkgs,
inputs,
self,
}: let
localPackages = import ../pkgs {inherit pkgs inputs;};
2026-07-04 09:30:16 +02:00
mkPkgs = overlays:
import inputs.nixpkgs {
system = pkgs.stdenv.hostPlatform.system;
config.allowUnfree = true;
2026-07-04 09:30:16 +02:00
inherit overlays;
};
2026-07-04 09:30:16 +02:00
upstreamPkgs = mkPkgs [];
modifiedPkgs = mkPkgs [self.overlays.modifications];
defaultPkgs = mkPkgs [self.overlays.default];
2026-07-10 12:42:04 +02:00
expectedVersion = "2.29.8";
expectedSrcHash = "sha256-+eiAdofrX1TRNFeD9MtTHt+XBH06c8NQHvTk6vrOU/k=";
expectedPnpmHash = "sha256-j0IrYjVl83SzRo29rhEDCQLrt8kslWHdS7m4pG11DgA=";
expectedChangelog = "https://github.com/n8n-io/n8n/releases/tag/n8n@${expectedVersion}";
2026-07-10 12:42:04 +02:00
expectedXlsxTarball = "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz";
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";
2026-07-04 09:30:16 +02:00
2026-07-10 12:42:04 +02:00
checkBuildPhaseInherited = overlayName: package:
if package.buildPhase != upstreamPkgs.n8n.buildPhase
2026-07-04 09:30:16 +02:00
then throw "${overlayName} n8n buildPhase should be inherited from upstream nixpkgs"
else "ok";
2026-07-05 18:41:05 +02:00
2026-07-10 12:42:04 +02:00
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";
checkXlsxTarballLock = overlayName: package:
pkgs.runCommand "${overlayName}-n8n-xlsx-tarball-lock-test" {
inherit expectedXlsxTarball;
2026-07-05 18:41:05 +02:00
} ''
2026-07-10 12:42:04 +02:00
grep -F "xlsx@$expectedXlsxTarball:" ${package.src}/pnpm-lock.yaml
grep -F "resolution: {tarball: $expectedXlsxTarball}" ${package.src}/pnpm-lock.yaml
2026-07-05 18:41:05 +02:00
touch $out
'';
in
pkgs.runCommand "n8n-overlay-test" {
2026-07-04 09:30:16 +02:00
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;
2026-07-10 12:42:04 +02:00
modificationsOverlayBuildPhase = checkBuildPhaseInherited "overlays.modifications" modifiedPkgs.n8n;
defaultOverlayBuildPhase = checkBuildPhaseInherited "overlays.default" defaultPkgs.n8n;
modificationsOverlayRootNodeModuleSymlinks = checkRootNodeModuleSymlinks "overlays.modifications" modifiedPkgs.n8n;
defaultOverlayRootNodeModuleSymlinks = checkRootNodeModuleSymlinks "overlays.default" defaultPkgs.n8n;
modificationsOverlayXlsxTarballLock = checkXlsxTarballLock "overlays.modifications" modifiedPkgs.n8n;
defaultOverlayXlsxTarballLock = checkXlsxTarballLock "overlays.default" defaultPkgs.n8n;
} ''
touch $out
''