<commit_before>{ config, lib, pkgs, options }:

with lib;

let cfg = config.services.prometheus.exporters.fastly;
in
{
  port = 9118;
  extraOpts = {
    debug = mkEnableOption "Debug logging mode for fastly-exporter";

    configFile = mkOption {
      type = types.nullOr types.path;
      default = null;
      description = ''
        Path to a fastly-exporter configuration file.
        Example one can be generated with <literal>fastly-exporter --config-file-example</literal>.
      '';
      example = "./fastly-exporter-config.txt";
    };

    tokenPath = mkOption {
      type = types.nullOr types.path;
      apply = final: if final == null then null else toString final;
      description = ''
        A run-time path to the token file, which is supposed to be provisioned
        outside of Nix store.
      '';
    };
  };
  serviceOpts = {
    script = ''
      ${optionalString (cfg.tokenPath != null)
      "export FASTLY_API_TOKEN=$(cat ${toString cfg.tokenPath})"}
      ${pkgs.fastly-exporter}/bin/fastly-exporter \
        -endpoint http://${cfg.listenAddress}:${cfg.port}/metrics
        ${optionalString cfg.debug "-debug true"} \
        ${optionalString cfg.configFile "-config-file ${cfg.configFile}"}
    '';
  };
}<commit_msg>services.prometheus.exporters.fastly: fixup broken module config<commit_after>{ config, lib, pkgs, options }:

with lib;

let cfg = config.services.prometheus.exporters.fastly;
in
{
  port = 9118;
  extraOpts = {
    debug = mkEnableOption "Debug logging mode for fastly-exporter";

    configFile = mkOption {
      type = types.nullOr types.path;
      default = null;
      description = ''
        Path to a fastly-exporter configuration file.
        Example one can be generated with <literal>fastly-exporter --config-file-example</literal>.
      '';
      example = "./fastly-exporter-config.txt";
    };

    tokenPath = mkOption {
      type = types.nullOr types.path;
      apply = final: if final == null then null else toString final;
      description = ''
        A run-time path to the token file, which is supposed to be provisioned
        outside of Nix store.
      '';
    };
  };
  serviceOpts = {
    script = ''
      ${optionalString (cfg.tokenPath != null)
      "export FASTLY_API_TOKEN=$(cat ${toString cfg.tokenPath})"}
      ${pkgs.prometheus-fastly-exporter}/bin/fastly-exporter \
        -endpoint http://${cfg.listenAddress}:${toString cfg.port}/metrics
        ${optionalString cfg.debug "-debug true"} \
        ${optionalString (cfg.configFile != null) "-config-file ${cfg.configFile}"}
    '';
  };
}
{'fraction_non_alphanumeric': 0.1268800617045893, 'fraction_numerical': 0.0030852294639413806, 'mean_word_length': 2.6535211267605634, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '6647309', 'n_tokens_mistral': 777, 'n_tokens_neox': 770, 'n_words': 202}