1{ config, lib, pkgs, options }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.tor; 7in 8{ 9 port = 9130; 10 extraOpts = { 11 torControlAddress = mkOption { 12 type = types.str; 13 default = "127.0.0.1"; 14 description = lib.mdDoc '' 15 Tor control IP address or hostname. 16 ''; 17 }; 18 19 torControlPort = mkOption { 20 type = types.port; 21 default = 9051; 22 description = lib.mdDoc '' 23 Tor control port. 24 ''; 25 }; 26 }; 27 serviceOpts = { 28 serviceConfig = { 29 ExecStart = '' 30 ${pkgs.prometheus-tor-exporter}/bin/prometheus-tor-exporter \ 31 -b ${cfg.listenAddress} \ 32 -p ${toString cfg.port} \ 33 -a ${cfg.torControlAddress} \ 34 -c ${toString cfg.torControlPort} \ 35 ${concatStringsSep " \\\n " cfg.extraFlags} 36 ''; 37 }; 38 39 # CPython requires a process to either have $HOME defined or run as a UID 40 # defined in /etc/passwd. The latter is false with DynamicUser, so define a 41 # dummy $HOME. https://bugs.python.org/issue10496 42 environment = { HOME = "/var/empty"; }; 43 }; 44}