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

with lib;

let
  cfg = config.services.bosun;

  configFile = pkgs.writeText "bosun.conf" ''
    tsdbHost = ${cfg.opentsdbHost}
    httpListen = ${cfg.listenAddress}
    stateFile = ${cfg.stateFile}
    checkFrequency = 5m

    ${cfg.extraConfig}
  '';

in {

  options = {

    services.bosun = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to run bosun.
        '';
      };

      package = mkOption {
        type = types.package;
        default = pkgs.bosun;
        example = literalExample "pkgs.bosun";
        description = ''
          bosun binary to use.
        '';
      };

      user = mkOption {
        type = types.string;
        default = "bosun";
        description = ''
          User account under which bosun runs.
        '';
      };

      group = mkOption {
        type = types.string;
        default = "bosun";
        description = ''
          Group account under which bosun runs.
        '';
      };

      opentsdbHost = mkOption {
        type = types.string;
        default = "localhost:4242";
        description = ''
          Host and port of the OpenTSDB database that stores bosun data.
        '';
      };

      listenAddress = mkOption {
        type = types.string;
        default = ":8070";
        description = ''
          The host address and port that bosun's web interface will listen on.
        '';
      };

      stateFile = mkOption {
        type = types.string;
        default = "/var/lib/bosun/bosun.state";
        description = ''
          Path to bosun's state file.
        '';
      };

      extraConfig = mkOption {
        type = types.string;
        default = "";
        description = ''<commit_msg>nixos/bosun: Make the check frequency configurable<commit_after>{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.bosun;

  configFile = pkgs.writeText "bosun.conf" ''
    tsdbHost = ${cfg.opentsdbHost}
    httpListen = ${cfg.listenAddress}
    stateFile = ${cfg.stateFile}
    checkFrequency = ${cfg.checkFrequency}

    ${cfg.extraConfig}
  '';

in {

  options = {

    services.bosun = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to run bosun.
        '';
      };

      package = mkOption {
        type = types.package;
        default = pkgs.bosun;
        example = literalExample "pkgs.bosun";
        description = ''
          bosun binary to use.
        '';
      };

      user = mkOption {
        type = types.string;
        default = "bosun";
        description = ''
          User account under which bosun runs.
        '';
      };

      group = mkOption {
        type = types.string;
        default = "bosun";
        description = ''
          Group account under which bosun runs.
        '';
      };

      opentsdbHost = mkOption {
        type = types.string;
        default = "localhost:4242";
        description = ''
          Host and port of the OpenTSDB database that stores bosun data.
        '';
      };

      listenAddress = mkOption {
        type = types.string;
        default = ":8070";
        description = ''
          The host address and port that bosun's web interface will listen on.
        '';
      };

      stateFile = mkOption {
        type = types.string;
        default = "/var/lib/bosun/bosun.state";
        description = ''
          Path to bosun's state file.
        '';
      };

      checkFrequency = mkOption {
        type = types.str;
        default = "5m";
        description = ''
          Bosun's check frequency
        '';
      };

      extraConfig = mkOption {
        type = types.string;
        default = "";
        description = ''
{'fraction_non_alphanumeric': 0.11183694800104521, 'fraction_numerical': 0.004703423046772929, 'mean_word_length': 1.5656836461126005, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '7547569', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1073, 'n_words': 275}