1 { config, lib, pkgs, ... }:
4 inherit (lib) mkEnableOption mkIf mkOption types;
6 cfg = config.services.tempo;
8 settingsFormat = pkgs.formats.yaml {};
10 options.services.tempo = {
11 enable = mkEnableOption (lib.mdDoc "Grafana Tempo");
14 type = settingsFormat.type;
16 description = lib.mdDoc ''
17 Specify the configuration for Tempo in Nix.
19 See https://grafana.com/docs/tempo/latest/configuration/ for available options.
23 configFile = mkOption {
24 type = types.nullOr types.path;
26 description = lib.mdDoc ''
27 Specify a path to a configuration file that Tempo should use.
32 config = mkIf cfg.enable {
33 # for tempo-cli and friends
34 environment.systemPackages = [ pkgs.tempo ];
38 (cfg.settings == {}) != (cfg.configFile == null)
41 Please specify a configuration for Tempo with either
42 'services.tempo.settings' or
43 'services.tempo.configFile'.
47 systemd.services.tempo = {
48 description = "Grafana Tempo Service Daemon";
49 wantedBy = [ "multi-user.target" ];
52 conf = if cfg.configFile == null
53 then settingsFormat.generate "config.yaml" cfg.settings
57 ExecStart = "${pkgs.tempo}/bin/tempo --config.file=${conf}";
60 ProtectSystem = "full";
61 DevicePolicy = "closed";
62 NoNewPrivileges = true;
63 WorkingDirectory = "/var/lib/tempo";
64 StateDirectory = "tempo";