2021-07-26 05:34:42 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2021-12-21 18:24:00 +00:00
|
|
|
|
2021-07-26 05:34:42 +01:00
|
|
|
with lib;
|
2021-12-21 18:24:00 +00:00
|
|
|
|
2021-07-26 05:34:42 +01:00
|
|
|
let
|
|
|
|
format = pkgs.formats.json { };
|
|
|
|
cfg = config.services.influxdb2;
|
|
|
|
configFile = format.generate "config.json" cfg.settings;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.influxdb2 = {
|
|
|
|
enable = mkEnableOption "the influxdb2 server";
|
2021-12-21 18:24:00 +00:00
|
|
|
|
2021-07-26 05:34:42 +01:00
|
|
|
package = mkOption {
|
2021-12-16 20:09:54 +00:00
|
|
|
default = pkgs.influxdb2-server;
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression "pkgs.influxdb2";
|
2021-07-26 05:34:42 +01:00
|
|
|
description = "influxdb2 derivation to use.";
|
|
|
|
type = types.package;
|
|
|
|
};
|
2021-12-21 18:24:00 +00:00
|
|
|
|
2021-07-26 05:34:42 +01:00
|
|
|
settings = mkOption {
|
|
|
|
default = { };
|
2021-11-15 08:12:15 +00:00
|
|
|
description = ''configuration options for influxdb2, see <link xlink:href="https://docs.influxdata.com/influxdb/v2.0/reference/config-options"/> for details.'';
|
2021-07-26 05:34:42 +01:00
|
|
|
type = format.type;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
assertions = [{
|
|
|
|
assertion = !(builtins.hasAttr "bolt-path" cfg.settings) && !(builtins.hasAttr "engine-path" cfg.settings);
|
|
|
|
message = "services.influxdb2.config: bolt-path and engine-path should not be set as they are managed by systemd";
|
|
|
|
}];
|
2021-12-21 18:24:00 +00:00
|
|
|
|
2021-07-26 05:34:42 +01:00
|
|
|
systemd.services.influxdb2 = {
|
|
|
|
description = "InfluxDB is an open-source, distributed, time series database";
|
|
|
|
documentation = [ "https://docs.influxdata.com/influxdb/" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
environment = {
|
2021-12-21 18:24:00 +00:00
|
|
|
INFLUXD_CONFIG_PATH = configFile;
|
2021-07-26 05:34:42 +01:00
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${cfg.package}/bin/influxd --bolt-path \${STATE_DIRECTORY}/influxd.bolt --engine-path \${STATE_DIRECTORY}/engine";
|
|
|
|
StateDirectory = "influxdb2";
|
2021-12-21 18:24:00 +00:00
|
|
|
User = "influxdb2";
|
|
|
|
Group = "influxdb2";
|
2021-07-26 05:34:42 +01:00
|
|
|
CapabilityBoundingSet = "";
|
|
|
|
SystemCallFilter = "@system-service";
|
|
|
|
LimitNOFILE = 65536;
|
|
|
|
KillMode = "control-group";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
2021-12-21 18:24:00 +00:00
|
|
|
|
|
|
|
users.extraUsers.influxdb2 = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "influxdb2";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraGroups.influxdb2 = {};
|
2021-07-26 05:34:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ nickcao ];
|
|
|
|
}
|