41 lines
1.3 KiB
Nix
41 lines
1.3 KiB
Nix
# Adds `libphonenumber-js` to n8n's node_modules so it can be require()'d
|
|
# from Code nodes running in the Task Runner.
|
|
#
|
|
# Prerequisite on the n8n service:
|
|
# N8N_RUNNERS_EXTERNAL_ALLOW = "libphonenumber-js";
|
|
#
|
|
# libphonenumber-js has zero runtime + peer dependencies, so a plain tarball
|
|
# unpack into the shared node_modules hierarchy is sufficient.
|
|
{prev}: let
|
|
libphonenumber-js = prev.stdenv.mkDerivation rec {
|
|
pname = "libphonenumber-js";
|
|
version = "1.13.8";
|
|
|
|
src = prev.fetchurl {
|
|
url = "https://registry.npmjs.org/${pname}/-/${pname}-${version}.tgz";
|
|
hash = "sha256-SysWDKlbXgbe441Sd4pO+k+F1y/UC49a1KL+DcFWBIA=";
|
|
};
|
|
|
|
dontConfigure = true;
|
|
dontBuild = true;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out/lib/node_modules/${pname}
|
|
cp -r * $out/lib/node_modules/${pname}/
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
in
|
|
prev.n8n.overrideAttrs (oldAttrs: {
|
|
postInstall =
|
|
(oldAttrs.postInstall or "")
|
|
+ ''
|
|
# n8n ships a pnpm stub symlink (libphonenumber-js -> empty-npm-package).
|
|
# Remove it and place the real package there instead.
|
|
rm -rf $out/lib/n8n/node_modules/libphonenumber-js
|
|
cp -r ${libphonenumber-js}/lib/node_modules/libphonenumber-js \
|
|
$out/lib/n8n/node_modules/
|
|
'';
|
|
})
|