dotfiles/modules/nixos/services/n8n.nix

41 lines
956 B
Nix
Raw Permalink Normal View History

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
2024-05-06 18:26:24 +00:00
config = lib.mkIf config.services.n8n.enable {
2022-12-21 21:18:03 +00:00
2024-05-06 18:38:03 +00:00
unfreePackages = [ "n8n" ];
2022-12-21 21:18:03 +00:00
services.n8n = {
2024-09-06 20:10:03 +00:00
webhookUrl = "https://${config.hostnames.n8n}";
2022-12-21 21:18:03 +00:00
settings = {
2024-05-08 03:46:03 +00:00
listen_address = "127.0.0.1";
port = 5678;
2024-09-06 20:10:03 +00:00
2022-12-21 21:18:03 +00:00
};
};
2024-09-06 20:10:03 +00:00
systemd.services.n8n.environment = {
N8N_EDITOR_BASE_URL = config.services.n8n.webhookUrl;
};
2024-05-06 18:26:24 +00:00
# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ config.hostnames.n8n ];
# Allow web traffic to Caddy
2024-04-20 13:42:06 +00:00
caddy.routes = [
{
2024-05-06 18:26:24 +00:00
match = [ { host = [ config.hostnames.n8n ]; } ];
2024-04-20 13:42:06 +00:00
handle = [
{
handler = "reverse_proxy";
2024-05-08 03:46:03 +00:00
upstreams = [ { dial = "localhost:${builtins.toString config.services.n8n.settings.port}"; } ];
2024-04-20 13:42:06 +00:00
}
];
}
];
2022-12-21 21:18:03 +00:00
};
2022-11-21 01:04:22 +00:00
}