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 "Grafana Tempo";
14 type = settingsFormat.type;
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;
27 Specify a path to a configuration file that Tempo should use.
31 extraFlags = mkOption {
32 type = types.listOf types.str;
34 example = lib.literalExpression
36 [ "-config.expand-env=true" ]
39 Additional flags to pass to the `ExecStart=` in `tempo.service`.
44 config = mkIf cfg.enable {
45 # for tempo-cli and friends
46 environment.systemPackages = [ pkgs.tempo ];
50 (cfg.settings == {}) != (cfg.configFile == null)
53 Please specify a configuration for Tempo with either
54 'services.tempo.settings' or
55 'services.tempo.configFile'.
59 systemd.services.tempo = {
60 description = "Grafana Tempo Service Daemon";
61 wantedBy = [ "multi-user.target" ];
64 conf = if cfg.configFile == null
65 then settingsFormat.generate "config.yaml" cfg.settings
69 ExecStart = "${pkgs.tempo}/bin/tempo --config.file=${conf} ${lib.escapeShellArgs cfg.extraFlags}";
72 ProtectSystem = "full";
73 DevicePolicy = "closed";
74 NoNewPrivileges = true;
75 WorkingDirectory = "/var/lib/tempo";
76 StateDirectory = "tempo";