Add n8n service
This commit is contained in:
parent
81bee0a7b9
commit
54fc411e13
8 changed files with 186 additions and 223 deletions
|
|
@ -6,6 +6,7 @@
|
|||
./forgejo.nix
|
||||
./immich.nix
|
||||
./media-mgr.nix
|
||||
./n8n.nix
|
||||
./nextcloud.nix
|
||||
./paperless-ngx.nix
|
||||
./plex.nix
|
||||
|
|
|
|||
80
modules/services/n8n.nix
Normal file
80
modules/services/n8n.nix
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.my.services.n8n;
|
||||
in
|
||||
{
|
||||
|
||||
options.my.services.n8n = {
|
||||
enable = lib.mkEnableOption "Enable n8n module";
|
||||
|
||||
environment = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.str;
|
||||
default = { };
|
||||
description = "Extra environment variables for n8n";
|
||||
example = {
|
||||
N8N_PROTOCOL = "https";
|
||||
WEBHOOK_URL = "https://n8n.example.com/";
|
||||
};
|
||||
};
|
||||
|
||||
proxy = {
|
||||
enable = lib.mkEnableOption "Set the proxy entry for this service";
|
||||
|
||||
domain = lib.mkOption {
|
||||
default = "example.com";
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The domain where Caddy is reachable
|
||||
'';
|
||||
};
|
||||
|
||||
subdomain = lib.mkOption {
|
||||
default = "n8n";
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
n8n subdomain
|
||||
'';
|
||||
};
|
||||
|
||||
host = lib.mkOption {
|
||||
default = "localhost";
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
host name where the service is running
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf cfg.enable {
|
||||
|
||||
services.n8n = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
environment = {
|
||||
GENERIC_TIMEZONE = "Europe/Rome";
|
||||
N8N_PROTOCOL = "https";
|
||||
WEBHOOK_URL = "https://${cfg.proxy.subdomain}.${cfg.proxy.domain}/";
|
||||
} // cfg.environment;
|
||||
};
|
||||
|
||||
})
|
||||
|
||||
(lib.mkIf cfg.proxy.enable {
|
||||
services.caddy = with cfg.proxy; {
|
||||
virtualHosts."${subdomain}.${domain}".extraConfig = ''
|
||||
reverse_proxy http://${host}:${services.n8n.environment.N8N_PORT}
|
||||
import cloudflare_${domain}
|
||||
'';
|
||||
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue