75 lines
1.9 KiB
Nix
75 lines
1.9 KiB
Nix
pkg:
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
cfg = config.services.noisebell-rss;
|
|
bin = "${pkg}/bin/noisebell-rss";
|
|
in
|
|
{
|
|
options.services.noisebell-rss = {
|
|
enable = lib.mkEnableOption "noisebell RSS service";
|
|
|
|
domain = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "Domain for the Caddy virtual host.";
|
|
};
|
|
|
|
port = lib.mkOption {
|
|
type = lib.types.port;
|
|
default = 3002;
|
|
};
|
|
|
|
cacheUrl = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "URL of the cache service (e.g. http://localhost:3000).";
|
|
};
|
|
|
|
httpTimeoutSecs = lib.mkOption {
|
|
type = lib.types.ints.positive;
|
|
default = 10;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
users.users.noisebell-rss = {
|
|
isSystemUser = true;
|
|
group = "noisebell-rss";
|
|
};
|
|
users.groups.noisebell-rss = { };
|
|
|
|
services.caddy.virtualHosts.${cfg.domain}.extraConfig = ''
|
|
reverse_proxy localhost:${toString cfg.port}
|
|
'';
|
|
|
|
systemd.services.noisebell-rss = {
|
|
description = "Noisebell RSS service";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network-online.target" ];
|
|
wants = [ "network-online.target" ];
|
|
environment = {
|
|
NOISEBELL_RSS_PORT = toString cfg.port;
|
|
NOISEBELL_RSS_CACHE_URL = cfg.cacheUrl;
|
|
NOISEBELL_RSS_HTTP_TIMEOUT_SECS = toString cfg.httpTimeoutSecs;
|
|
RUST_LOG = "info";
|
|
};
|
|
script = ''
|
|
exec ${bin}
|
|
'';
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
Restart = "on-failure";
|
|
RestartSec = 5;
|
|
User = "noisebell-rss";
|
|
Group = "noisebell-rss";
|
|
NoNewPrivileges = true;
|
|
ProtectSystem = "strict";
|
|
ProtectHome = true;
|
|
PrivateTmp = true;
|
|
ProtectKernelTunables = true;
|
|
ProtectKernelModules = true;
|
|
ProtectControlGroups = true;
|
|
RestrictSUIDSGID = true;
|
|
};
|
|
};
|
|
};
|
|
}
|