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

with lib;
let
  cfg = config.services.tt-rss;

  configVersion = 26;

  cacheDir = "cache";
  lockDir = "lock";
  feedIconsDir = "feed-icons";

  dbPort = if cfg.database.port == null
    then (if cfg.database.type == "pgsql" then 5432 else 3306)
    else cfg.database.port;

  poolName = "tt-rss";
  phpfpmSocketName = "/var/run/phpfpm/${poolName}.sock";

  tt-rss-config = pkgs.writeText "config.php" ''
    <?php

      define('PHP_EXECUTABLE', '${pkgs.php}/bin/php');

      define('LOCK_DIRECTORY', '${lockDir}');
      define('CACHE_DIR', '${cacheDir}');
      define('ICONS_DIR', '${feedIconsDir}');
      define('ICONS_URL', '${feedIconsDir}');
      define('SELF_URL_PATH', '${cfg.selfUrlPath}');

      define('MYSQL_CHARSET', 'UTF8');

      define('DB_TYPE', '${cfg.database.type}');
      define('DB_HOST', '${optionalString (cfg.database.host != null) cfg.database.host}');
      define('DB_USER', '${cfg.database.user}');
      define('DB_NAME', '${cfg.database.name}');
      define('DB_PASS', ${
        if (cfg.database.password != null) then
          "'${(escape ["'" "\\"] cfg.database.password)}'"
        else if (cfg.database.passwordFile != null) then
          "file_get_contents('${cfg.database.passwordFile}')"
        else
          ""
      });
      define('DB_PORT', '${toString dbPort}');

      define('AUTH_AUTO_CREATE', ${boolToString cfg.auth.autoCreate});
      define('AUTH_AUTO_LOGIN', ${boolToString cfg.auth.autoLogin});

      define('FEED_CRYPT_KEY', '${escape ["'" "\\"] cfg.feedCryptKey}');


      define('SINGLE_USER_MODE', ${boolToString cfg.singleUserMode});

      define('SIMPLE_UPDATE_MODE', ${boolToString cfg.simpleUpdateMode});

      // Never check for updates - the running version of the code should be
      // controlled entirely by the version of TT-RSS active in the current Nix
      // profile. If TT-RSS updates itself to a version requiring a database
      // schema upgrade, and then the SystemD tt-rss.service is restarted, the
      // old code copied from the Nix store will overwrite the updated version,
      // causing the code to detect the need for a schema "upgrade" (since the
      // schema version in the database is different than in the code), but the
      // update schema operation in TT-RSS will do nothing because the schema
      // version in the database is newer than that in the code.<commit_msg>tt-rss: Fix syntax error in config.php DB_PASS field<commit_after>{ config, lib, pkgs, ... }:

with lib;
let
  cfg = config.services.tt-rss;

  configVersion = 26;

  cacheDir = "cache";
  lockDir = "lock";
  feedIconsDir = "feed-icons";

  dbPort = if cfg.database.port == null
    then (if cfg.database.type == "pgsql" then 5432 else 3306)
    else cfg.database.port;

  poolName = "tt-rss";
  phpfpmSocketName = "/var/run/phpfpm/${poolName}.sock";

  tt-rss-config = pkgs.writeText "config.php" ''
    <?php

      define('PHP_EXECUTABLE', '${pkgs.php}/bin/php');

      define('LOCK_DIRECTORY', '${lockDir}');
      define('CACHE_DIR', '${cacheDir}');
      define('ICONS_DIR', '${feedIconsDir}');
      define('ICONS_URL', '${feedIconsDir}');
      define('SELF_URL_PATH', '${cfg.selfUrlPath}');

      define('MYSQL_CHARSET', 'UTF8');

      define('DB_TYPE', '${cfg.database.type}');
      define('DB_HOST', '${optionalString (cfg.database.host != null) cfg.database.host}');
      define('DB_USER', '${cfg.database.user}');
      define('DB_NAME', '${cfg.database.name}');
      define('DB_PASS', ${
        if (cfg.database.password != null) then
          "'${(escape ["'" "\\"] cfg.database.password)}'"
        else if (cfg.database.passwordFile != null) then
          "file_get_contents('${cfg.database.passwordFile}')"
        else
          "''"
      });
      define('DB_PORT', '${toString dbPort}');

      define('AUTH_AUTO_CREATE', ${boolToString cfg.auth.autoCreate});
      define('AUTH_AUTO_LOGIN', ${boolToString cfg.auth.autoLogin});

      define('FEED_CRYPT_KEY', '${escape ["'" "\\"] cfg.feedCryptKey}');


      define('SINGLE_USER_MODE', ${boolToString cfg.singleUserMode});

      define('SIMPLE_UPDATE_MODE', ${boolToString cfg.simpleUpdateMode});

      // Never check for updates - the running version of the code should be
      // controlled entirely by the version of TT-RSS active in the current Nix
      // profile. If TT-RSS updates itself to a version requiring a database
      // schema upgrade, and then the SystemD tt-rss.service is restarted, the
      // old code copied from the Nix store will overwrite the updated version,
      // causing the code to detect the need for a schema "upgrade" (since the
      // schema version in the database is different than in the code), but the
      // update schema operation in TT-RSS will do nothing because the schema
      // version in the database is newer than that in the code.
{'fraction_non_alphanumeric': 0.15373650987578905, 'fraction_numerical': 0.004479739360619018, 'mean_word_length': 3.1697792869269947, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6333822', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1485, 'n_words': 408}