<commit_before>{ config, lib, pkgs }:

with lib;

let
  cfg = config.services.prometheus.exporters.tor;
in
{
  port = 9130;
  extraOpts = {
    torControlAddress = mkOption {
      type = types.str;
      default = "127.0.0.1";
      description = ''
        Tor control IP address or hostname.
      '';
    };

    torControlPort = mkOption {
      type = types.int;
      default = 9051;
      description = ''
        Tor control port.
      '';
    };
  };
  serviceOpts = {
    serviceConfig = {
      DynamicUser = true;
      ExecStart = ''
        ${pkgs.prometheus-tor-exporter}/bin/prometheus-tor-exporter \
          -b ${cfg.listenAddress} \
          -p ${toString cfg.port} \
          -a ${cfg.torControlAddress} \
          -c ${toString cfg.torControlPort} \
          ${concatStringsSep " \\\n  " cfg.extraFlags}
      '';
    };
  };
}<commit_msg>prometheus/exporters/tor: make CPython happy by defining $HOME<commit_after>{ config, lib, pkgs }:

with lib;

let
  cfg = config.services.prometheus.exporters.tor;
in
{
  port = 9130;
  extraOpts = {
    torControlAddress = mkOption {
      type = types.str;
      default = "127.0.0.1";
      description = ''
        Tor control IP address or hostname.
      '';
    };

    torControlPort = mkOption {
      type = types.int;
      default = 9051;
      description = ''
        Tor control port.
      '';
    };
  };
  serviceOpts = {
    serviceConfig = {
      DynamicUser = true;
      ExecStart = ''
        ${pkgs.prometheus-tor-exporter}/bin/prometheus-tor-exporter \
          -b ${cfg.listenAddress} \
          -p ${toString cfg.port} \
          -a ${cfg.torControlAddress} \
          -c ${toString cfg.torControlPort} \
          ${concatStringsSep " \\\n  " cfg.extraFlags}
      '';
    };

    # CPython requires a process to either have $HOME defined or run as a UID
    # defined in /etc/passwd. The latter is false with DynamicUser, so define a
    # dummy $HOME. https://bugs.python.org/issue10496
    environment = { HOME = "/var/empty"; };
  };
}
{'fraction_non_alphanumeric': 0.1323529411764706, 'fraction_numerical': 0.016176470588235296, 'mean_word_length': 1.9324712643678161, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5562382', 'n_tokens_mistral': 684, 'n_tokens_neox': 651, 'n_words': 148}