Files
nixpkgs/overlays/mods/n8n.nix
T
m3tam3re 5477cfc71b feat: add automatic n8n overlay updates
- overlays/mods/n8n.nix: add passthru.updateScript pointing to ./update.sh
- overlays/mods/update.sh: self-contained updater that fetches the latest
  stable n8n-io/n8n release, recomputes both src and pnpmDeps hashes
  (src via nix-prefetch-url with --name workaround for the `@` in the tag,
  pnpmDeps via the lib.fakeHash mismatch trick)
- .gitea/workflows/nix-update.yml: discover and run overlays/mods/*/update.sh
  after the pkgs/ loop; verify step skips overlay/* entries (covered by flake check)

The test suite (tests/n8n-overlay-test.nix) forbids exporting a local n8n
package, so the overlay cannot be exposed via pkgs/n8n/ — the workflow gets
an explicit overlay-discovery block instead.
2026-07-26 12:09:22 +02:00

53 lines
1.9 KiB
Nix

{prev}: let
xlsxTarball = "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz";
xlsxIntegrity = "sha512-+nKZ39+nvK7Qq6i0PvWWRA4j/EkfWOtkP/YhMtupm+lJIiHxUrgTr1CcKv1nBk1rHtkRRQ3O2+Ih/q/sA+FXZA==";
patchXlsxLockfile = ''
substituteInPlace pnpm-lock.yaml \
--replace-fail \
"resolution: {tarball: ${xlsxTarball}}" \
"resolution: {integrity: ${xlsxIntegrity}, tarball: ${xlsxTarball}}"
'';
in
prev.n8n.overrideAttrs (finalAttrs: previousAttrs: {
version = "2.31.6";
src = prev.fetchFromGitHub {
owner = "n8n-io";
repo = "n8n";
tag = "n8n@${finalAttrs.version}";
hash = "sha256-OTVfIHnGTaBogEd93Ak2Pu3Jh7VweQNYbUeahq1Z/64=";
};
pnpmDeps = prev.fetchPnpmDeps {
inherit (finalAttrs) pname version src;
pnpm = prev.pnpm_10;
fetcherVersion = 3;
prePnpmInstall = patchXlsxLockfile;
hash = "sha256-Q3HCJg1KjdRJnPZJEUKcaCrh8tBhT9B3gqMz8xbBZVg=";
};
prePnpmInstall = (previousAttrs.prePnpmInstall or "") + patchXlsxLockfile;
preBuild =
(previousAttrs.preBuild or "")
+ ''
if [ ! -e node_modules/sass-embedded ] && [ -e node_modules/.pnpm/node_modules/sass-embedded ]; then
ln -s .pnpm/node_modules/sass-embedded node_modules/sass-embedded
fi
if [ ! -e node_modules/sqlite3 ] && [ -e node_modules/.pnpm/node_modules/sqlite3 ]; then
ln -s .pnpm/node_modules/sqlite3 node_modules/sqlite3
fi
'';
# Self-contained update script (./update.sh) — fetches latest stable
# release from n8n-io/n8n, recomputes both src and pnpmDeps hashes.
# The CI workflow in .gitea/workflows/nix-update.yml discovers and runs it.
passthru = (previousAttrs.passthru or {}) // {updateScript = ./update.sh;};
meta =
previousAttrs.meta
// {
changelog = "https://github.com/n8n-io/n8n/releases/tag/n8n@${finalAttrs.version}";
};
})