Merge pull request #154036 from K900/regener8n
This commit is contained in:
commit
053e56be55
6 changed files with 3140 additions and 1718 deletions
|
@ -43,6 +43,7 @@ in
|
||||||
# This folder must be writeable as the application is storing
|
# This folder must be writeable as the application is storing
|
||||||
# its data in it, so the StateDirectory is a good choice
|
# its data in it, so the StateDirectory is a good choice
|
||||||
N8N_USER_FOLDER = "/var/lib/n8n";
|
N8N_USER_FOLDER = "/var/lib/n8n";
|
||||||
|
HOME = "/var/lib/n8n";
|
||||||
N8N_CONFIG_FILES = "${configFile}";
|
N8N_CONFIG_FILES = "${configFile}";
|
||||||
};
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{ pkgs, nodejs, stdenv, lib, ... }:
|
{ pkgs, nodejs-14_x, stdenv, lib }:
|
||||||
|
|
||||||
let
|
let
|
||||||
nodePackages = import ./node-composition.nix {
|
nodePackages = import ./node-composition.nix {
|
||||||
inherit pkgs nodejs;
|
inherit pkgs;
|
||||||
|
nodejs = nodejs-14_x;
|
||||||
inherit (stdenv.hostPlatform) system;
|
inherit (stdenv.hostPlatform) system;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
@ -10,9 +11,10 @@ nodePackages.n8n.override {
|
||||||
nativeBuildInputs = with pkgs.nodePackages; [
|
nativeBuildInputs = with pkgs.nodePackages; [
|
||||||
node-pre-gyp
|
node-pre-gyp
|
||||||
];
|
];
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Free and open fair-code licensed node based Workflow Automation Tool";
|
description = "Free and open fair-code licensed node based Workflow Automation Tool";
|
||||||
maintainers = with maintainers; [ freezeboy ];
|
maintainers = with maintainers; [ freezeboy k900 ];
|
||||||
license = licenses.asl20;
|
license = licenses.asl20;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,19 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#! nix-shell -i bash -p nodePackages.node2nix
|
#! nix-shell -i bash -p nodePackages.node2nix
|
||||||
|
|
||||||
|
# --strip-optional-dependencies to get rid of deprecated build deps:
|
||||||
|
#
|
||||||
|
# n8n
|
||||||
|
# -> n8n-nodes-base
|
||||||
|
# -> ssh2-sftp-client
|
||||||
|
# -> ssh2
|
||||||
|
# -> cpu-features
|
||||||
|
# -> node-gyp@3.8.0 -> python2
|
||||||
|
# -> cmake
|
||||||
|
|
||||||
node2nix \
|
node2nix \
|
||||||
|
--14 \
|
||||||
|
--strip-optional-dependencies \
|
||||||
--node-env node-env.nix \
|
--node-env node-env.nix \
|
||||||
--input package.json \
|
--input package.json \
|
||||||
--output node-packages.nix \
|
--output node-packages.nix \
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
nodeEnv = import ./node-env.nix {
|
nodeEnv = import ./node-env.nix {
|
||||||
inherit (pkgs) stdenv lib python2 runCommand writeTextFile;
|
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
|
||||||
inherit pkgs nodejs;
|
inherit pkgs nodejs;
|
||||||
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
|
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# This file originates from node2nix
|
# This file originates from node2nix
|
||||||
|
|
||||||
{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile}:
|
{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript}:
|
||||||
|
|
||||||
let
|
let
|
||||||
# Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master
|
# Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master
|
||||||
|
@ -40,36 +40,22 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
includeDependencies = {dependencies}:
|
# Common shell logic
|
||||||
lib.optionalString (dependencies != [])
|
installPackage = writeShellScript "install-package" ''
|
||||||
(lib.concatMapStrings (dependency:
|
installPackage() {
|
||||||
''
|
local packageName=$1 src=$2
|
||||||
# Bundle the dependencies of the package
|
|
||||||
mkdir -p node_modules
|
|
||||||
cd node_modules
|
|
||||||
|
|
||||||
# Only include dependencies if they don't exist. They may also be bundled in the package.
|
local strippedName
|
||||||
if [ ! -e "${dependency.name}" ]
|
|
||||||
then
|
|
||||||
${composePackage dependency}
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd ..
|
local DIR=$PWD
|
||||||
''
|
|
||||||
) dependencies);
|
|
||||||
|
|
||||||
# Recursively composes the dependencies of a package
|
|
||||||
composePackage = { name, packageName, src, dependencies ? [], ... }@args:
|
|
||||||
builtins.addErrorContext "while evaluating node package '${packageName}'" ''
|
|
||||||
DIR=$(pwd)
|
|
||||||
cd $TMPDIR
|
cd $TMPDIR
|
||||||
|
|
||||||
unpackFile ${src}
|
unpackFile $src
|
||||||
|
|
||||||
# Make the base dir in which the target dependency resides first
|
# Make the base dir in which the target dependency resides first
|
||||||
mkdir -p "$(dirname "$DIR/${packageName}")"
|
mkdir -p "$(dirname "$DIR/$packageName")"
|
||||||
|
|
||||||
if [ -f "${src}" ]
|
if [ -f "$src" ]
|
||||||
then
|
then
|
||||||
# Figure out what directory has been unpacked
|
# Figure out what directory has been unpacked
|
||||||
packageDir="$(find . -maxdepth 1 -type d | tail -1)"
|
packageDir="$(find . -maxdepth 1 -type d | tail -1)"
|
||||||
|
@ -79,28 +65,53 @@ let
|
||||||
chmod -R u+w "$packageDir"
|
chmod -R u+w "$packageDir"
|
||||||
|
|
||||||
# Move the extracted tarball into the output folder
|
# Move the extracted tarball into the output folder
|
||||||
mv "$packageDir" "$DIR/${packageName}"
|
mv "$packageDir" "$DIR/$packageName"
|
||||||
elif [ -d "${src}" ]
|
elif [ -d "$src" ]
|
||||||
then
|
then
|
||||||
# Get a stripped name (without hash) of the source directory.
|
# Get a stripped name (without hash) of the source directory.
|
||||||
# On old nixpkgs it's already set internally.
|
# On old nixpkgs it's already set internally.
|
||||||
if [ -z "$strippedName" ]
|
if [ -z "$strippedName" ]
|
||||||
then
|
then
|
||||||
strippedName="$(stripHash ${src})"
|
strippedName="$(stripHash $src)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore write permissions to make building work
|
# Restore write permissions to make building work
|
||||||
chmod -R u+w "$strippedName"
|
chmod -R u+w "$strippedName"
|
||||||
|
|
||||||
# Move the extracted directory into the output folder
|
# Move the extracted directory into the output folder
|
||||||
mv "$strippedName" "$DIR/${packageName}"
|
mv "$strippedName" "$DIR/$packageName"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unset the stripped name to not confuse the next unpack step
|
# Change to the package directory to install dependencies
|
||||||
unset strippedName
|
cd "$DIR/$packageName"
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
# Include the dependencies of the package
|
# Bundle the dependencies of the package
|
||||||
cd "$DIR/${packageName}"
|
#
|
||||||
|
# Only include dependencies if they don't exist. They may also be bundled in the package.
|
||||||
|
includeDependencies = {dependencies}:
|
||||||
|
lib.optionalString (dependencies != []) (
|
||||||
|
''
|
||||||
|
mkdir -p node_modules
|
||||||
|
cd node_modules
|
||||||
|
''
|
||||||
|
+ (lib.concatMapStrings (dependency:
|
||||||
|
''
|
||||||
|
if [ ! -e "${dependency.name}" ]; then
|
||||||
|
${composePackage dependency}
|
||||||
|
fi
|
||||||
|
''
|
||||||
|
) dependencies)
|
||||||
|
+ ''
|
||||||
|
cd ..
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
# Recursively composes the dependencies of a package
|
||||||
|
composePackage = { name, packageName, src, dependencies ? [], ... }@args:
|
||||||
|
builtins.addErrorContext "while evaluating node package '${packageName}'" ''
|
||||||
|
installPackage "${packageName}" "${src}"
|
||||||
${includeDependencies { inherit dependencies; }}
|
${includeDependencies { inherit dependencies; }}
|
||||||
cd ..
|
cd ..
|
||||||
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
||||||
|
@ -391,13 +402,14 @@ let
|
||||||
, dontStrip ? true
|
, dontStrip ? true
|
||||||
, unpackPhase ? "true"
|
, unpackPhase ? "true"
|
||||||
, buildPhase ? "true"
|
, buildPhase ? "true"
|
||||||
|
, meta ? {}
|
||||||
, ... }@args:
|
, ... }@args:
|
||||||
|
|
||||||
let
|
let
|
||||||
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ];
|
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation ({
|
||||||
name = "node_${name}-${version}";
|
name = "${name}-${version}";
|
||||||
buildInputs = [ tarWrapper python nodejs ]
|
buildInputs = [ tarWrapper python nodejs ]
|
||||||
++ lib.optional (stdenv.isLinux) utillinux
|
++ lib.optional (stdenv.isLinux) utillinux
|
||||||
++ lib.optional (stdenv.isDarwin) libtool
|
++ lib.optional (stdenv.isDarwin) libtool
|
||||||
|
@ -414,6 +426,8 @@ let
|
||||||
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
|
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
source ${installPackage}
|
||||||
|
|
||||||
# Create and enter a root node_modules/ folder
|
# Create and enter a root node_modules/ folder
|
||||||
mkdir -p $out/lib/node_modules
|
mkdir -p $out/lib/node_modules
|
||||||
cd $out/lib/node_modules
|
cd $out/lib/node_modules
|
||||||
|
@ -446,6 +460,11 @@ let
|
||||||
# Run post install hook, if provided
|
# Run post install hook, if provided
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
# default to Node.js' platforms
|
||||||
|
platforms = nodejs.meta.platforms;
|
||||||
|
} // meta;
|
||||||
} // extraArgs);
|
} // extraArgs);
|
||||||
|
|
||||||
# Builds a node environment (a node_modules folder and a set of binaries)
|
# Builds a node environment (a node_modules folder and a set of binaries)
|
||||||
|
@ -486,6 +505,8 @@ let
|
||||||
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
|
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
source ${installPackage}
|
||||||
|
|
||||||
mkdir -p $out/${packageName}
|
mkdir -p $out/${packageName}
|
||||||
cd $out/${packageName}
|
cd $out/${packageName}
|
||||||
|
|
||||||
|
|
4746
pkgs/applications/networking/n8n/node-packages.nix
generated
4746
pkgs/applications/networking/n8n/node-packages.nix
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue