{ config, inputs, lib, libNginx, this, ... }: let cfg = config.nixfiles.modules.tempo; in { options.nixfiles.modules.tempo = { enable = lib.mkEnableOption "Tempo"; port = lib.mkOption { description = "Port."; type = lib.types.port; default = 30181; }; domain = lib.mkOption { description = "Domain name sans protocol scheme."; type = lib.types.str; default = "tempo.${config.networking.domain}"; }; }; config = lib.mkIf cfg.enable { nixfiles.modules.nginx = { enable = true; upstreams.tempo.servers."127.0.0.1:${toString cfg.port}" = { }; virtualHosts.${cfg.domain} = { locations."/".proxyPass = "http://tempo"; extraConfig = libNginx.config.internalOnly; }; }; services.tempo = { enable = true; settings = rec { multitenancy_enabled = false; server = { http_listen_address = "127.0.0.1"; http_listen_port = cfg.port; grpc_listen_address = "0.0.0.0"; grpc_listen_port = server.http_listen_port + 1; log_format = "logfmt"; log_level = "warn"; log_source_ips_enabled = true; }; storage.trace.backend = "local"; memberlist = { bind_port = 7947; message_history_buffer_bytes = lib.pow 2 13; }; compactor.compaction.block_retention = "168h"; }; }; topology.nodes.${this.hostname}.services.tempo = { name = "Tempo"; icon = "${inputs.homelab-svg-assets}/assets/tempo.svg"; info = cfg.domain; details.listen.text = "127.0.0.1:${toString cfg.port}"; }; }; }