-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
n8n: new service #1630
base: main
Are you sure you want to change the base?
n8n: new service #1630
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ ... }: | ||
{ } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
allowUnfree: true |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,86 @@ | ||||||||||||||
{ config | ||||||||||||||
, lib | ||||||||||||||
, pkgs | ||||||||||||||
, ... | ||||||||||||||
}: | ||||||||||||||
|
||||||||||||||
with lib; | ||||||||||||||
|
||||||||||||||
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
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"; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
address = lib.mkOption { | ||||||||||||||
type = types.str; | ||||||||||||||
description = "Listen address"; | ||||||||||||||
default = "127.0.0.1"; | ||||||||||||||
example = "127.0.0.1"; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
port = lib.mkOption { | ||||||||||||||
type = types.port; | ||||||||||||||
default = 5432; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default in their docs is
Suggested change
|
||||||||||||||
description = '' | ||||||||||||||
The TCP port to accept connections. | ||||||||||||||
''; | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
webhookUrl = lib.mkOption { | ||||||||||||||
type = lib.types.str; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Suggested change
|
||||||||||||||
default = ""; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
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;) | ||||||||||||||
''; | ||||||||||||||
}]; | ||||||||||||||
Comment on lines
+56
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no need to assert this.
Suggested change
|
||||||||||||||
env = { | ||||||||||||||
N8N_PORT = cfg.port; | ||||||||||||||
N8N_LISTEN_ADDRESS = cfg.address; | ||||||||||||||
WEBHOOK_URL = "${cfg.webhookUrl}"; | ||||||||||||||
N8N_CONFIG_FILES = "${configFile}"; | ||||||||||||||
Comment on lines
+65
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should work, no?
Suggested change
|
||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
processes.n8n = { | ||||||||||||||
exec = "${pkgs.n8n}/bin/n8n"; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's nice to have a |
||||||||||||||
|
||||||||||||||
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"; | ||||||||||||||
}; | ||||||||||||||
}; | ||||||||||||||
}; | ||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To test that it launches, you can add a |
||
services.n8n = { | ||
enable = true; | ||
address = "0.0.0.0"; | ||
port = 5678; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
allowUnfree: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
n8n
can be removed in favor of the test.