2024-01-10 04:11:11 +00:00
|
|
|
# n8n is an automation integration tool for connecting data from services
|
|
|
|
# together with triggers.
|
|
|
|
|
2024-04-20 13:42:06 +00:00
|
|
|
{ config, lib, ... }:
|
|
|
|
{
|
2022-11-21 01:04:22 +00:00
|
|
|
|
2022-12-21 21:18:03 +00:00
|
|
|
options = {
|
|
|
|
n8nServer = lib.mkOption {
|
2022-12-22 00:31:25 +00:00
|
|
|
type = lib.types.nullOr lib.types.str;
|
2022-12-21 21:18:03 +00:00
|
|
|
description = "Hostname for n8n automation";
|
|
|
|
default = null;
|
2022-11-21 01:04:22 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-21 21:38:34 +00:00
|
|
|
config = lib.mkIf (config.n8nServer != null) {
|
2022-12-21 21:18:03 +00:00
|
|
|
|
|
|
|
services.n8n = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
n8n = {
|
|
|
|
listenAddress = "127.0.0.1";
|
|
|
|
port = 5678;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-20 13:42:06 +00:00
|
|
|
caddy.routes = [
|
|
|
|
{
|
|
|
|
match = [ { host = [ config.n8nServer ]; } ];
|
|
|
|
handle = [
|
|
|
|
{
|
|
|
|
handler = "reverse_proxy";
|
|
|
|
upstreams = [ { dial = "localhost:5678"; } ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2022-12-21 21:18:03 +00:00
|
|
|
};
|
2022-11-21 01:04:22 +00:00
|
|
|
}
|