-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efa9010
commit 8c87d38
Showing
6 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
[comment]: # (Please add your documentation on top of this line) | ||
|
||
@AUTOGEN_OPTIONS@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ ... }: | ||
{ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
allowUnfree: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ config | ||
, lib | ||
, pkgs | ||
, ... | ||
}: | ||
|
||
with lib; | ||
|
||
let | ||
inherit (lib) types; | ||
cfg = config.services.n8n; | ||
format = pkgs.formats.json { }; | ||
configFile = format.generate "n8n.json" cfg.settings; | ||
in | ||
{ | ||
options = { | ||
services.n8n = { | ||
enable = mkEnableOption "n8n"; | ||
|
||
address = lib.mkOption { | ||
type = types.str; | ||
description = "Listen address"; | ||
default = "127.0.0.1"; | ||
example = "127.0.0.1"; | ||
}; | ||
|
||
port = lib.mkOption { | ||
type = types.port; | ||
default = 5432; | ||
description = '' | ||
The TCP port to accept connections. | ||
''; | ||
}; | ||
|
||
webhookUrl = lib.mkOption { | ||
type = lib.types.str; | ||
default = ""; | ||
description = '' | ||
WEBHOOK_URL for n8n, in case we're running behind a reverse proxy. | ||
This cannot be set through configuration and must reside in an environment variable. | ||
''; | ||
}; | ||
|
||
settings = lib.mkOption { | ||
type = format.type; | ||
default = { }; | ||
description = '' | ||
Configuration for n8n, see <https://docs.n8n.io/hosting/environment-variables/configuration-methods/> | ||
for supported values. | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
assertions = [{ | ||
assertion = cfg.enable; | ||
message = '' | ||
To use n8n, you have to enable it. (services.n8n.enable = true;) | ||
''; | ||
}]; | ||
env = { | ||
N8N_PORT = cfg.port; | ||
N8N_LISTEN_ADDRESS = cfg.address; | ||
WEBHOOK_URL = "${cfg.webhookUrl}"; | ||
N8N_CONFIG_FILES = "${configFile}"; | ||
}; | ||
|
||
processes.n8n = { | ||
exec = "${pkgs.n8n}/bin/n8n"; | ||
|
||
process-compose = { | ||
readiness_probe = { | ||
exec.command = "${pkgs.curl}/bin/curl -f -k ${cfg.address}:${toString cfg.port}"; | ||
initial_delay_seconds = 1; | ||
period_seconds = 10; | ||
timeout_seconds = 2; | ||
success_threshold = 1; | ||
failure_threshold = 5; | ||
}; | ||
|
||
availability.restart = "on_failure"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
services.n8n = { | ||
enable = true; | ||
address = "0.0.0.0"; | ||
port = 5678; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
allowUnfree: true |