fix: zulip to use domain and webhooks api properly
This commit is contained in:
parent
3a0d464234
commit
e2f2b96919
1 changed files with 51 additions and 47 deletions
|
|
@ -10,8 +10,9 @@ in
|
|||
enable = lib.mkEnableOption "noisebell Zulip bridge";
|
||||
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Domain for the Caddy virtual host.";
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
description = "Optional domain for the Caddy virtual host.";
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
|
|
@ -57,51 +58,54 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users.noisebell-zulip = {
|
||||
isSystemUser = true;
|
||||
group = "noisebell-zulip";
|
||||
};
|
||||
users.groups.noisebell-zulip = { };
|
||||
|
||||
services.caddy.virtualHosts.${cfg.domain}.extraConfig = ''
|
||||
reverse_proxy localhost:${toString cfg.port}
|
||||
'';
|
||||
|
||||
systemd.services.noisebell-zulip = {
|
||||
description = "Noisebell Zulip bridge";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
environment = {
|
||||
NOISEBELL_ZULIP_PORT = toString cfg.port;
|
||||
NOISEBELL_ZULIP_SITE_URL = cfg.zulipUrl;
|
||||
NOISEBELL_ZULIP_BOT_EMAIL = cfg.botEmail;
|
||||
NOISEBELL_ZULIP_STREAM = cfg.stream;
|
||||
NOISEBELL_ZULIP_TOPIC = cfg.topic;
|
||||
NOISEBELL_ZULIP_IMAGE_BASE_URL = cfg.imageBaseUrl;
|
||||
RUST_LOG = "info";
|
||||
config = lib.mkIf cfg.enable (
|
||||
{
|
||||
users.users.noisebell-zulip = {
|
||||
isSystemUser = true;
|
||||
group = "noisebell-zulip";
|
||||
};
|
||||
script = ''
|
||||
export NOISEBELL_ZULIP_API_KEY="$(cat ${cfg.apiKeyFile})"
|
||||
export NOISEBELL_ZULIP_WEBHOOK_SECRET="$(cat ${cfg.webhookSecretFile})"
|
||||
exec ${bin}
|
||||
users.groups.noisebell-zulip = { };
|
||||
|
||||
systemd.services.noisebell-zulip = {
|
||||
description = "Noisebell Zulip bridge";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
environment = {
|
||||
NOISEBELL_ZULIP_PORT = toString cfg.port;
|
||||
NOISEBELL_ZULIP_SITE_URL = cfg.zulipUrl;
|
||||
NOISEBELL_ZULIP_BOT_EMAIL = cfg.botEmail;
|
||||
NOISEBELL_ZULIP_STREAM = cfg.stream;
|
||||
NOISEBELL_ZULIP_TOPIC = cfg.topic;
|
||||
NOISEBELL_ZULIP_IMAGE_BASE_URL = cfg.imageBaseUrl;
|
||||
RUST_LOG = "info";
|
||||
};
|
||||
script = ''
|
||||
export NOISEBELL_ZULIP_API_KEY="$(cat ${cfg.apiKeyFile})"
|
||||
export NOISEBELL_ZULIP_WEBHOOK_SECRET="$(cat ${cfg.webhookSecretFile})"
|
||||
exec ${bin}
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
User = "noisebell-zulip";
|
||||
Group = "noisebell-zulip";
|
||||
NoNewPrivileges = true;
|
||||
ProtectSystem = "strict";
|
||||
ProtectHome = true;
|
||||
PrivateTmp = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectControlGroups = true;
|
||||
RestrictSUIDSGID = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
// lib.mkIf (cfg.domain != null) {
|
||||
services.caddy.virtualHosts.${cfg.domain}.extraConfig = ''
|
||||
reverse_proxy localhost:${toString cfg.port}
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
User = "noisebell-zulip";
|
||||
Group = "noisebell-zulip";
|
||||
NoNewPrivileges = true;
|
||||
ProtectSystem = "strict";
|
||||
ProtectHome = true;
|
||||
PrivateTmp = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectControlGroups = true;
|
||||
RestrictSUIDSGID = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue