···
8
+
cfg = config.services.corteza;
11
+
options.services.corteza = {
12
+
enable = lib.mkEnableOption "Corteza, a low-code platform";
13
+
package = lib.mkPackageOption pkgs "corteza" { };
15
+
address = lib.mkOption {
16
+
type = lib.types.str;
17
+
default = "0.0.0.0";
19
+
IP for the HTTP server.
22
+
port = lib.mkOption {
23
+
type = lib.types.port;
26
+
Port for the HTTP server.
29
+
openFirewall = lib.mkOption {
30
+
type = lib.types.bool;
33
+
description = "Whether to open ports in the firewall.";
36
+
user = lib.mkOption {
37
+
type = lib.types.str;
38
+
default = "corteza";
39
+
description = "The user to run Corteza under.";
42
+
group = lib.mkOption {
43
+
type = lib.types.str;
44
+
default = "corteza";
45
+
description = "The group to run Corteza under.";
48
+
settings = lib.mkOption {
49
+
type = lib.types.submodule {
50
+
freeformType = lib.types.attrsOf lib.types.str;
52
+
HTTP_WEBAPP_ENABLED = lib.mkEnableOption "webapps" // {
60
+
Configuration for Corteza, will be passed as environment variables.
61
+
See <https://docs.cortezaproject.org/corteza-docs/2024.9/devops-guide/references/configuration/server.html>.
66
+
config = lib.mkIf cfg.enable {
69
+
assertion = !cfg.settings ? HTTP_ADDR;
70
+
message = "Use `services.corteza.address` and `services.corteza.port` instead.";
74
+
warnings = lib.optional (!cfg.settings ? DB_DSN) ''
75
+
A database connection string is not set.
76
+
Corteza will create a temporary SQLite database in memory, but it will not persist data.
77
+
For production use, set `services.corteza.settings.DB_DSN`.
80
+
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.port ];
82
+
systemd.services.corteza = {
83
+
description = "Corteza";
84
+
documentation = [ "https://docs.cortezaproject.org/" ];
85
+
after = [ "network-online.target" ];
86
+
wants = [ "network-online.target" ];
87
+
wantedBy = [ "multi-user.target" ];
89
+
HTTP_WEBAPP_BASE_DIR = "./webapp";
90
+
HTTP_ADDR = "${cfg.address}:${toString cfg.port}";
92
+
path = [ pkgs.dart-sass ];
94
+
WorkingDirectory = cfg.package;
97
+
ExecStart = "${lib.getExe cfg.package} serve-api";
102
+
groups.${cfg.group} = { };
103
+
users.${cfg.user} = {
104
+
inherit (cfg) group;
105
+
isSystemUser = true;
110
+
meta.maintainers = with lib.maintainers; [