at 22.05-pre 1.9 kB view raw
1{ config, lib, pkgs, ... }: 2with lib; 3let 4 format = pkgs.formats.json { }; 5 cfg = config.services.influxdb2; 6 configFile = format.generate "config.json" cfg.settings; 7in 8{ 9 options = { 10 services.influxdb2 = { 11 enable = mkEnableOption "the influxdb2 server"; 12 package = mkOption { 13 default = pkgs.influxdb2; 14 defaultText = literalExpression "pkgs.influxdb2"; 15 description = "influxdb2 derivation to use."; 16 type = types.package; 17 }; 18 settings = mkOption { 19 default = { }; 20 description = ''configuration options for influxdb2, see <link xlink:href="https://docs.influxdata.com/influxdb/v2.0/reference/config-options"/> for details.''; 21 type = format.type; 22 }; 23 }; 24 }; 25 26 config = mkIf cfg.enable { 27 assertions = [{ 28 assertion = !(builtins.hasAttr "bolt-path" cfg.settings) && !(builtins.hasAttr "engine-path" cfg.settings); 29 message = "services.influxdb2.config: bolt-path and engine-path should not be set as they are managed by systemd"; 30 }]; 31 systemd.services.influxdb2 = { 32 description = "InfluxDB is an open-source, distributed, time series database"; 33 documentation = [ "https://docs.influxdata.com/influxdb/" ]; 34 wantedBy = [ "multi-user.target" ]; 35 after = [ "network.target" ]; 36 environment = { 37 INFLUXD_CONFIG_PATH = "${configFile}"; 38 }; 39 serviceConfig = { 40 ExecStart = "${cfg.package}/bin/influxd --bolt-path \${STATE_DIRECTORY}/influxd.bolt --engine-path \${STATE_DIRECTORY}/engine"; 41 StateDirectory = "influxdb2"; 42 DynamicUser = true; 43 CapabilityBoundingSet = ""; 44 SystemCallFilter = "@system-service"; 45 LimitNOFILE = 65536; 46 KillMode = "control-group"; 47 Restart = "on-failure"; 48 }; 49 }; 50 }; 51 52 meta.maintainers = with lib.maintainers; [ nickcao ]; 53}