dotfiles/nixos/services/n8n.nix

34 lines
628 B
Nix
Raw Normal View History

2022-12-21 21:18:03 +00:00
{ config, pkgs, 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;
};
};
};
caddy.routes = [{
match = [{ host = [ config.n8nServer ]; }];
handle = [{
handler = "reverse_proxy";
upstreams = [{ dial = "localhost:5678"; }];
}];
2022-11-21 01:04:22 +00:00
}];
2022-12-21 21:18:03 +00:00
};
2022-11-21 01:04:22 +00:00
}