about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorK900 <me@0upti.me>2022-07-10 14:01:30 +0300
committerGitHub <noreply@github.com>2022-07-10 14:01:30 +0300
commitd2b579b23ef70f7c45af4b2268989511278f57fc (patch)
treec275f553e71f4a2abe191124358c20edc3feee81 /nixos/modules
parent97d5a1a5919c7124fc22405cf43098e3cfa8ea45 (diff)
parent03dd01dd2fbba721f9f1a4c757e55cf2c6e15345 (diff)
downloadnixlib-d2b579b23ef70f7c45af4b2268989511278f57fc.tar
nixlib-d2b579b23ef70f7c45af4b2268989511278f57fc.tar.gz
nixlib-d2b579b23ef70f7c45af4b2268989511278f57fc.tar.bz2
nixlib-d2b579b23ef70f7c45af4b2268989511278f57fc.tar.lz
nixlib-d2b579b23ef70f7c45af4b2268989511278f57fc.tar.xz
nixlib-d2b579b23ef70f7c45af4b2268989511278f57fc.tar.zst
nixlib-d2b579b23ef70f7c45af4b2268989511278f57fc.zip
Merge pull request #178254 from K900/update-tempo
tempo: 1.1.0 -> 1.4.1, add NixOS module
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/tracing/tempo.nix68
2 files changed, 69 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 034d6ba1f582..3a06694130bc 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -1033,6 +1033,7 @@
   ./services/torrent/peerflix.nix
   ./services/torrent/rtorrent.nix
   ./services/torrent/transmission.nix
+  ./services/tracing/tempo.nix
   ./services/ttys/getty.nix
   ./services/ttys/gpm.nix
   ./services/ttys/kmscon.nix
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";
+      };
+    };
+  };
+}