From 5c2478ba3cc2e66a2373c6ff9946346e2f746f8c Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Mon, 26 Jul 2021 12:34:42 +0800 Subject: [PATCH] nixos/influxdb2: init --- .../from_md/release-notes/rl-2111.section.xml | 8 +++ .../manual/release-notes/rl-2111.section.md | 2 + nixos/modules/module-list.nix | 1 + .../modules/services/databases/influxdb2.nix | 53 +++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 nixos/modules/services/databases/influxdb2.nix diff --git a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml index f241bff0760f..6203de9d6d16 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml @@ -156,6 +156,14 @@ moonraker. + + + influxdb2, + a Scalable datastore for metrics, events, and real-time + analytics. Available as + services.influxdb2. + +
diff --git a/nixos/doc/manual/release-notes/rl-2111.section.md b/nixos/doc/manual/release-notes/rl-2111.section.md index 13cb08e2c9a3..1dd43977f211 100644 --- a/nixos/doc/manual/release-notes/rl-2111.section.md +++ b/nixos/doc/manual/release-notes/rl-2111.section.md @@ -48,6 +48,8 @@ pt-services.clipcat.enable). - [moonraker](https://github.com/Arksine/moonraker), an API web server for Klipper. Available as [moonraker](#opt-services.moonraker.enable). +- [influxdb2](https://github.com/influxdata/influxdb), a Scalable datastore for metrics, events, and real-time analytics. Available as [services.influxdb2](#opt-services.influxdb2.enable). + ## Backward Incompatibilities {#sec-release-21.11-incompatibilities} - The `staticjinja` package has been upgraded from 1.0.4 to 3.0.1 diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 4276a625ed6c..c9a124544f83 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -321,6 +321,7 @@ ./services/databases/foundationdb.nix ./services/databases/hbase.nix ./services/databases/influxdb.nix + ./services/databases/influxdb2.nix ./services/databases/memcached.nix ./services/databases/monetdb.nix ./services/databases/mongodb.nix diff --git a/nixos/modules/services/databases/influxdb2.nix b/nixos/modules/services/databases/influxdb2.nix new file mode 100644 index 000000000000..df7bac4261b5 --- /dev/null +++ b/nixos/modules/services/databases/influxdb2.nix @@ -0,0 +1,53 @@ +{ config, lib, pkgs, ... }: +with lib; +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"; + package = mkOption { + default = pkgs.influxdb2; + defaultText = "pkgs.influxdb2"; + description = "influxdb2 derivation to use."; + type = types.package; + }; + settings = mkOption { + default = { }; + description = "configuration options for influxdb2, see https://docs.influxdata.com/influxdb/v2.0/reference/config-options for details."; + 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"; + }]; + 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 = { + INFLUXD_CONFIG_PATH = "${configFile}"; + }; + serviceConfig = { + ExecStart = "${cfg.package}/bin/influxd --bolt-path \${STATE_DIRECTORY}/influxd.bolt --engine-path \${STATE_DIRECTORY}/engine"; + StateDirectory = "influxdb2"; + DynamicUser = true; + CapabilityBoundingSet = ""; + SystemCallFilter = "@system-service"; + LimitNOFILE = 65536; + KillMode = "control-group"; + Restart = "on-failure"; + }; + }; + }; + + meta.maintainers = with lib.maintainers; [ nickcao ]; +}