1 { config, lib, pkgs, ... }:
6 cfg = config.services.tremor-rs;
8 loggerSettingsFormat = pkgs.formats.yaml { };
9 loggerConfigFile = loggerSettingsFormat.generate "logger.yaml" cfg.loggerSettings;
13 services.tremor-rs = {
14 enable = lib.mkEnableOption "Tremor event- or stream-processing system";
16 troyFileList = mkOption {
17 type = types.listOf types.path;
19 description = "List of troy files to load.";
22 tremorLibDir = mkOption {
25 description = "Directory where to find /lib containing tremor script files";
30 default = "127.0.0.1";
31 description = "The host tremor should be listening on";
37 description = "the port tremor should be listening on";
40 loggerSettings = mkOption {
41 description = "Tremor logger configuration";
43 type = loggerSettingsFormat.type;
46 refresh_rate = "30 seconds";
47 appenders.stdout.kind = "console";
50 appenders = [ "stdout" ];
55 appenders = [ "stdout" ];
60 appenders = [ "stdout" ];
66 defaultText = literalExpression ''
68 refresh_rate = "30 seconds";
69 appenders.stdout.kind = "console";
72 appenders = [ "stdout" ];
77 appenders = [ "stdout" ];
82 appenders = [ "stdout" ];
93 config = mkIf (cfg.enable) {
95 environment.systemPackages = [ pkgs.tremor-rs ] ;
97 systemd.services.tremor-rs = {
98 description = "Tremor event- or stream-processing system";
99 wantedBy = [ "multi-user.target" ];
100 requires = [ "network-online.target" ];
101 after = [ "network-online.target" ];
103 environment.TREMOR_PATH = "${pkgs.tremor-rs}/lib:${cfg.tremorLibDir}";
106 ExecStart = "${pkgs.tremor-rs}/bin/tremor --logger-config ${loggerConfigFile} server run ${concatStringsSep " " cfg.troyFileList} --api-host ${cfg.host}:${toString cfg.port}";
109 NoNewPrivileges = true;
113 ProtectProc = "noaccess";
115 ProtectKernelLogs = true;
116 ProtectKernelModules = true;
117 ProtectKernelTunables = true;
118 ProtectControlGroups = true;
119 ProtectHostname = true;
120 RestrictSUIDSGID = true;
121 RestrictRealtime = true;
122 RestrictNamespaces = true;
123 LockPersonality = true;
125 SystemCallFilter = [ "@system-service" "~@privileged" ];