diff --git a/mastus/ttrss.nix b/mastus/ttrss.nix index a15e992..4d6ca4c 100644 --- a/mastus/ttrss.nix +++ b/mastus/ttrss.nix @@ -14,8 +14,6 @@ ''; }; - nixpkgs.config.packageOverrides = pkgs: { tt-rss = pkgs.callPackage ./ttrss/drv.nix {}; }; - imports = [ ./ttrss/mod.nix ]; services.tt-rss = { enable = true; user = "ttrss"; @@ -37,18 +35,20 @@ log_level = notice ''; - poolConfigs = { - ttrss = '' - listen = 9000 - user = ttrss - pm = dynamic - pm.max_children = 75 - pm.start_servers = 10 - pm.min_spare_servers = 5 - pm.max_spare_servers = 20 - pm.max_requests = 500 - catch_workers_output = 1 - ''; + pools = { + ttrss = { + listen = "9000"; + extraConfig = '' + user = ttrss + pm = dynamic + pm.max_children = 75 + pm.start_servers = 10 + pm.min_spare_servers = 5 + pm.max_spare_servers = 20 + pm.max_requests = 500 + catch_workers_output = 1 + ''; + }; }; }; diff --git a/mastus/ttrss/drv.nix b/mastus/ttrss/drv.nix deleted file mode 100644 index e5bef6e..0000000 --- a/mastus/ttrss/drv.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ stdenv, fetchgit }: - -stdenv.mkDerivation rec { - name = "tt-rss-${version}"; - version = "16.3"; - - src = fetchgit { - url = "https://tt-rss.org/gitlab/fox/tt-rss.git"; - rev = "refs/tags/${version}"; - sha256 = "1584lcq6kcy9f8ik5djb9apck9hxvfpl54sn6yhl3pdfrfdj3nw5"; - }; - - buildPhases = ["unpackPhase" "installPhase"]; - - installPhase = '' - mkdir $out - cp -ra * $out/ - ''; - - meta = with stdenv.lib; { - description = "Web-based news feed (RSS/Atom) aggregator"; - license = licenses.gpl2Plus; - homepage = http://tt-rss.org; - platforms = platforms.all; - }; -} - diff --git a/mastus/ttrss/mod.nix b/mastus/ttrss/mod.nix deleted file mode 100644 index 7d38862..0000000 --- a/mastus/ttrss/mod.nix +++ /dev/null @@ -1,502 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; -let - cfg = config.services.tt-rss; - - configVersion = 26; - - boolToString = b: if b then "true" else "false"; - - 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; - - tt-rss-config = pkgs.stdenv.mkDerivation { - name = "tt-rss-config"; - - buildCommand = let - cfgFile = pkgs.writeText "config.php" '' - System), syslog - logs to system log. - Setting this to blank uses PHP logging (usually to http server - error.log). - ''; - }; - }; - }; - - - ###### implementation - - config = mkIf cfg.enable { - - systemd.services.tt-rss = let - dbService = if cfg.database.type == "pgsql" then "postgresql.service" else "mysql.service"; - in { - - description = "Tiny Tiny RSS feeds update daemon"; - - preStart = let - root = "/var/lib/tt-rss"; - - callSql = if cfg.database.type == "pgsql" then (e: '' - ${optionalString (cfg.database.password != null) - "PGPASSWORD=${cfg.database.password}"} ${pkgs.postgresql95}/bin/psql \ - -U ${cfg.database.user} \ - -h ${cfg.database.host} \ - --port ${toString dbPort} \ - -c '${e}' \ - ${cfg.database.name}'') - - else if cfg.database.type == "mysql" then (e: '' - echo '${e}' | ${pkgs.mysql}/bin/mysql \ - ${optionalString (cfg.database.password != null) - "-p${cfg.database.password}"} \ - -u ${cfg.database.user} \ - -h ${cfg.database.host} \ - -P ${toString dbPort} \ - ${cfg.database.name}'') - - else ""; - - in '' - rm -rf "${root}/*" - mkdir -m 755 -p "${root}" - cp -r "${pkgs.tt-rss}/"* "${root}" - ln -sf "${tt-rss-config}" "${root}/config.php" - chown -R "${cfg.user}" "${root}" - chmod -R 755 "${root}" - '' + (optionalString (cfg.database.type == "pgsql") '' - - exists=$(${callSql "select count(*) > 0 from pg_tables where tableowner = user"} \ - | tail -n+3 | head -n-2 | sed -e 's/[ \n\t]*//') - - if [ "$exists" == 'f' ]; then - ${callSql "\\i ${pkgs.tt-rss}/schema/ttrss_schema_${cfg.database.type}.sql"} - else - echo 'The database contains some data. Leaving it as it is.' - fi; - '') + (optionalString (cfg.database.type == "mysql") '' - - exists=$(${callSql "select count(*) > 0 from information_schema.tables where table_schema = schema()"} \ - | tail -n+2 | sed -e 's/[ \n\t]*//') - - if [ "$exists" == '0' ]; then - ${callSql "\\. ${pkgs.tt-rss}/schema/ttrss_schema_${cfg.database.type}.sql"} - else - echo 'The database contains some data. Leaving it as it is.' - fi; - ''); - - serviceConfig = { - User = "${cfg.user}"; - ExecStart = "${pkgs.php}/bin/php /var/lib/tt-rss/update.php --daemon"; - StandardOutput = "syslog"; - StandardError = "syslog"; - PermissionsStartOnly = true; - }; - - wantedBy = [ "multi-user.target" ]; - requires = ["${dbService}"]; - after = ["network.target" "${dbService}"]; - }; - }; -} -