2022-11-18 17:20:05 -05:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.tremor-rs;
|
|
|
|
|
|
|
|
loggerSettingsFormat = pkgs.formats.yaml { };
|
|
|
|
loggerConfigFile = loggerSettingsFormat.generate "logger.yaml" cfg.loggerSettings;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.tremor-rs = {
|
|
|
|
enable = lib.mkEnableOption "Tremor event- or stream-processing system";
|
|
|
|
|
2024-08-30 00:47:05 +02:00
|
|
|
troyFileList = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.path;
|
2022-11-18 17:20:05 -05:00
|
|
|
default = [ ];
|
|
|
|
description = "List of troy files to load.";
|
|
|
|
};
|
|
|
|
|
2024-08-30 00:47:05 +02:00
|
|
|
tremorLibDir = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
2022-11-18 17:20:05 -05:00
|
|
|
default = "";
|
|
|
|
description = "Directory where to find /lib containing tremor script files";
|
|
|
|
};
|
|
|
|
|
2024-08-30 00:47:05 +02:00
|
|
|
host = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-11-18 17:20:05 -05:00
|
|
|
default = "127.0.0.1";
|
|
|
|
description = "The host tremor should be listening on";
|
|
|
|
};
|
|
|
|
|
2024-08-30 00:47:05 +02:00
|
|
|
port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
2022-11-18 17:20:05 -05:00
|
|
|
default = 9898;
|
|
|
|
description = "the port tremor should be listening on";
|
|
|
|
};
|
|
|
|
|
2024-08-30 00:47:05 +02:00
|
|
|
loggerSettings = lib.mkOption {
|
2022-11-18 17:20:05 -05:00
|
|
|
description = "Tremor logger configuration";
|
|
|
|
default = { };
|
|
|
|
type = loggerSettingsFormat.type;
|
|
|
|
|
|
|
|
example = {
|
|
|
|
refresh_rate = "30 seconds";
|
|
|
|
appenders.stdout.kind = "console";
|
|
|
|
root = {
|
|
|
|
level = "warn";
|
|
|
|
appenders = [ "stdout" ];
|
|
|
|
};
|
|
|
|
loggers = {
|
|
|
|
tremor_runtime = {
|
|
|
|
level = "debug";
|
|
|
|
appenders = [ "stdout" ];
|
|
|
|
additive = false;
|
|
|
|
};
|
|
|
|
tremor = {
|
|
|
|
level = "debug";
|
|
|
|
appenders = [ "stdout" ];
|
|
|
|
additive = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-30 00:47:05 +02:00
|
|
|
defaultText = lib.literalExpression ''
|
2022-11-18 17:20:05 -05:00
|
|
|
{
|
|
|
|
refresh_rate = "30 seconds";
|
|
|
|
appenders.stdout.kind = "console";
|
|
|
|
root = {
|
|
|
|
level = "warn";
|
|
|
|
appenders = [ "stdout" ];
|
|
|
|
};
|
|
|
|
loggers = {
|
|
|
|
tremor_runtime = {
|
|
|
|
level = "debug";
|
|
|
|
appenders = [ "stdout" ];
|
|
|
|
additive = false;
|
|
|
|
};
|
|
|
|
tremor = {
|
|
|
|
level = "debug";
|
|
|
|
appenders = [ "stdout" ];
|
|
|
|
additive = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-30 00:47:05 +02:00
|
|
|
config = lib.mkIf (cfg.enable) {
|
2022-11-18 17:20:05 -05:00
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.tremor-rs ];
|
|
|
|
|
|
|
|
systemd.services.tremor-rs = {
|
|
|
|
description = "Tremor event- or stream-processing system";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
requires = [ "network-online.target" ];
|
|
|
|
after = [ "network-online.target" ];
|
|
|
|
|
|
|
|
environment.TREMOR_PATH = "${pkgs.tremor-rs}/lib:${cfg.tremorLibDir}";
|
|
|
|
|
|
|
|
serviceConfig = {
|
2024-08-30 00:47:05 +02:00
|
|
|
ExecStart = "${pkgs.tremor-rs}/bin/tremor --logger-config ${loggerConfigFile} server run ${lib.concatStringsSep " " cfg.troyFileList} --api-host ${cfg.host}:${toString cfg.port}";
|
2022-11-18 17:20:05 -05:00
|
|
|
DynamicUser = true;
|
|
|
|
Restart = "always";
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectProc = "noaccess";
|
|
|
|
ProcSubset = "pid";
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
LockPersonality = true;
|
|
|
|
RemoveIPC = true;
|
|
|
|
SystemCallFilter = [
|
|
|
|
"@system-service"
|
|
|
|
"~@privileged"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|