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

with pkgs.lib;

let

  inherit (pkgs) prayer;

  stateDir = "/var/lib/prayer";

  prayerUser = "prayer";
  prayerGroup = "prayer";

  prayerExtraCfg = pkgs.writeText "extraprayer.cf" ''
    prefix = "${prayer}"
    var_prefix = "${stateDir}"
    prayer_user = "${prayerUser}"
    prayer_group = "${prayerGroup}"
    sendmail_path = "/var/setuid-wrappers/sendmail"

    ${config.services.prayer.extraConfig}
  '';

  prayerCfg = pkgs.runCommand "prayer.cf" { } ''
    cat ${prayer}/etc/prayer.cf ${prayerExtraCfg} > $out
  '';

in

{

  ###### interface

  options = {

    services.prayer = {

      enable = mkOption {
        default = false;
        description = ''
          Whether to run the machine as a HTTP proxy server.
        '';
      };

      listenAddress = mkOption {
        default = "127.0.0.1:8118";
        description = ''
          Address the proxy server is listening to.
        '';
      };

      logDir = mkOption {
        default = "/var/log/prayer" ;
        description = ''
          Location for prayer log files.
        '';
      };

      extraConfig = mkOption {
        default = "" ;
        description = ''
          Extra configuration. Contents will be added verbatim to the configuration file.
        '';
      };
    };

  };


  ###### implementation

  config = mkIf config.services.prayer.enable {
    environment.systemPackages = [ prayer ];

    users.extraUsers = singleton
      { name = prayerUser;
        uid = config.ids.uids.prayer;
        description = "prayer daemon user";<commit_msg>Fixing documentation about the prayer module, and adding a port setting, defaulting to something other than 80 at least.<commit_after>{ config, pkgs, ... }:

with pkgs.lib;

let

  inherit (pkgs) prayer;

  cfg = config.services.prayer;

  stateDir = "/var/lib/prayer";

  prayerUser = "prayer";
  prayerGroup = "prayer";

  prayerExtraCfg = pkgs.writeText "extraprayer.cf" ''
    prefix = "${prayer}"
    var_prefix = "${stateDir}"
    prayer_user = "${prayerUser}"
    prayer_group = "${prayerGroup}"
    sendmail_path = "/var/setuid-wrappers/sendmail"

    use_http_port ${cfg.port}

    ${cfg.extraConfig}
  '';

  prayerCfg = pkgs.runCommand "prayer.cf" { } ''
    cat ${prayer}/etc/prayer.cf ${prayerExtraCfg} > $out
  '';

in

{

  ###### interface

  options = {

    services.prayer = {

      enable = mkOption {
        default = false;
        description = ''
          Whether to run the prayer webmail http server.
        '';
      };

      port = mkOption {
        default = "2080";
        description = ''
          Port the prayer http server is listening to.
        '';
      };

      extraConfig = mkOption {
        default = "" ;
        description = ''
          Extra configuration. Contents will be added verbatim to the configuration file.
        '';
      };
    };

  };


  ###### implementation

  config = mkIf config.services.prayer.enable {
    environment.systemPackages = [ prayer ];

    users.extraUsers = singleton
      { name = prayerUser;
        uid = config.ids.uids.prayer;
        description = "prayer daemon user";
{'fraction_non_alphanumeric': 0.13077897403419886, 'fraction_numerical': 0.00506649778340722, 'mean_word_length': 2.1876892028254287, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '1772322', 'n_tokens_mistral': 989, 'n_tokens_neox': 952, 'n_words': 226}