diff options
author | K900 <me@0upti.me> | 2022-06-19 17:08:48 +0300 |
---|---|---|
committer | K900 <me@0upti.me> | 2022-07-08 21:33:17 +0300 |
commit | 03dd01dd2fbba721f9f1a4c757e55cf2c6e15345 (patch) | |
tree | d767a253705129abf969a63d12c21e416898877c /nixos/modules/services/tracing | |
parent | c29a4892723e6ca61c5425cbce714bb89384e0b5 (diff) |
nixos: add module for tempo
It's very barebones but should be OK for now.
Diffstat (limited to 'nixos/modules/services/tracing')
-rw-r--r-- | nixos/modules/services/tracing/tempo.nix | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/nixos/modules/services/tracing/tempo.nix b/nixos/modules/services/tracing/tempo.nix new file mode 100644 index 000000000000..15491a51c8e9 --- /dev/null +++ b/nixos/modules/services/tracing/tempo.nix @@ -0,0 +1,68 @@ +{ config, lib, pkgs, ... }: + +let + inherit (lib) mkEnableOption mkIf mkOption types; + + cfg = config.services.tempo; + + settingsFormat = pkgs.formats.yaml {}; +in { + options.services.tempo = { + enable = mkEnableOption "Grafana Tempo"; + + settings = mkOption { + type = settingsFormat.type; + default = {}; + description = '' + Specify the configuration for Tempo in Nix. + + See https://grafana.com/docs/tempo/latest/configuration/ for available options. + ''; + }; + + configFile = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + Specify a path to a configuration file that Tempo should use. + ''; + }; + }; + + config = mkIf cfg.enable { + # for tempo-cli and friends + environment.systemPackages = [ pkgs.tempo ]; + + assertions = [{ + assertion = ( + (cfg.settings == {}) != (cfg.configFile == null) + ); + message = '' + Please specify a configuration for Tempo with either + 'services.tempo.settings' or + 'services.tempo.configFile'. + ''; + }]; + + systemd.services.tempo = { + description = "Grafana Tempo Service Daemon"; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = let + conf = if cfg.configFile == null + then settingsFormat.generate "config.yaml" cfg.settings + else cfg.configFile; + in + { + ExecStart = "${pkgs.tempo}/bin/tempo --config.file=${conf}"; + DynamicUser = true; + Restart = "always"; + ProtectSystem = "full"; + DevicePolicy = "closed"; + NoNewPrivileges = true; + WorkingDirectory = "/var/lib/tempo"; + StateDirectory = "tempo"; + }; + }; + }; +} |