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

57 lines
2.4 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];
expectedVersion = "2.29.4";
expectedSrcHash = "sha256-Vc10fXKn21PSlv6Sk+5zyi2efkKup1Vi+9+vyJd2I1k=";
expectedPnpmHash = "sha256-2UFKP5bo06afaMPD+dIYQ7O0NiyZai4i8vkidi7HfxE=";
expectedChangelog = "https://github.com/n8n-io/n8n/releases/tag/n8n@${expectedVersion}";
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
checkPhasesInherited = overlayName: package:
if (package.preBuild or null) != (upstreamPkgs.n8n.preBuild or null)
then throw "${overlayName} n8n preBuild should be inherited from upstream nixpkgs"
else if package.buildPhase != upstreamPkgs.n8n.buildPhase
then throw "${overlayName} n8n buildPhase should be inherited from upstream nixpkgs"
else "ok";
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-04 09:30:16 +02:00
modificationsOverlayPhases = checkPhasesInherited "overlays.modifications" modifiedPkgs.n8n;
defaultOverlayPhases = checkPhasesInherited "overlays.default" defaultPkgs.n8n;
} ''
touch $out
''