2016-06-05 18:55:46 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.tt-rss;
|
|
|
|
|
2023-12-27 16:03:51 +00:00
|
|
|
inherit (cfg) phpPackage;
|
|
|
|
|
2016-06-05 18:55:46 +00:00
|
|
|
configVersion = 26;
|
|
|
|
|
|
|
|
dbPort = if cfg.database.port == null
|
|
|
|
then (if cfg.database.type == "pgsql" then 5432 else 3306)
|
|
|
|
else cfg.database.port;
|
|
|
|
|
|
|
|
poolName = "tt-rss";
|
|
|
|
|
2019-07-06 02:04:56 +00:00
|
|
|
mysqlLocal = cfg.database.createLocally && cfg.database.type == "mysql";
|
|
|
|
pgsqlLocal = cfg.database.createLocally && cfg.database.type == "pgsql";
|
|
|
|
|
2021-07-01 19:38:04 +00:00
|
|
|
tt-rss-config = let
|
|
|
|
password =
|
|
|
|
if (cfg.database.password != null) then
|
2021-12-05 11:02:30 +00:00
|
|
|
"'${(escape ["'" "\\"] cfg.database.password)}'"
|
2021-07-01 19:38:04 +00:00
|
|
|
else if (cfg.database.passwordFile != null) then
|
2021-12-05 11:02:30 +00:00
|
|
|
"file_get_contents('${cfg.database.passwordFile}')"
|
2021-07-01 19:38:04 +00:00
|
|
|
else
|
2021-12-11 13:01:15 +00:00
|
|
|
null
|
2021-07-01 19:38:04 +00:00
|
|
|
;
|
|
|
|
in pkgs.writeText "config.php" ''
|
2016-06-05 18:55:46 +00:00
|
|
|
<?php
|
2023-12-27 16:03:51 +00:00
|
|
|
putenv('TTRSS_PHP_EXECUTABLE=${phpPackage}/bin/php');
|
2021-07-01 19:38:04 +00:00
|
|
|
|
2021-08-08 12:00:00 +00:00
|
|
|
putenv('TTRSS_LOCK_DIRECTORY=${cfg.root}/lock');
|
|
|
|
putenv('TTRSS_CACHE_DIR=${cfg.root}/cache');
|
|
|
|
putenv('TTRSS_ICONS_DIR=${cfg.root}/feed-icons');
|
|
|
|
putenv('TTRSS_ICONS_URL=feed-icons');
|
2021-07-01 19:38:04 +00:00
|
|
|
putenv('TTRSS_SELF_URL_PATH=${cfg.selfUrlPath}');
|
|
|
|
|
|
|
|
putenv('TTRSS_MYSQL_CHARSET=UTF8');
|
|
|
|
|
|
|
|
putenv('TTRSS_DB_TYPE=${cfg.database.type}');
|
|
|
|
putenv('TTRSS_DB_HOST=${optionalString (cfg.database.host != null) cfg.database.host}');
|
|
|
|
putenv('TTRSS_DB_USER=${cfg.database.user}');
|
|
|
|
putenv('TTRSS_DB_NAME=${cfg.database.name}');
|
2021-12-11 13:01:15 +00:00
|
|
|
putenv('TTRSS_DB_PASS=' ${optionalString (password != null) ". ${password}"});
|
2021-07-01 19:38:04 +00:00
|
|
|
putenv('TTRSS_DB_PORT=${toString dbPort}');
|
|
|
|
|
|
|
|
putenv('TTRSS_AUTH_AUTO_CREATE=${boolToString cfg.auth.autoCreate}');
|
|
|
|
putenv('TTRSS_AUTH_AUTO_LOGIN=${boolToString cfg.auth.autoLogin}');
|
|
|
|
|
|
|
|
putenv('TTRSS_FEED_CRYPT_KEY=${escape ["'" "\\"] cfg.feedCryptKey}');
|
|
|
|
|
|
|
|
|
|
|
|
putenv('TTRSS_SINGLE_USER_MODE=${boolToString cfg.singleUserMode}');
|
|
|
|
|
|
|
|
putenv('TTRSS_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.
|
|
|
|
putenv('TTRSS_CHECK_FOR_UPDATES=false');
|
|
|
|
|
|
|
|
putenv('TTRSS_FORCE_ARTICLE_PURGE=${toString cfg.forceArticlePurge}');
|
|
|
|
putenv('TTRSS_SESSION_COOKIE_LIFETIME=${toString cfg.sessionCookieLifetime}');
|
|
|
|
putenv('TTRSS_ENABLE_GZIP_OUTPUT=${boolToString cfg.enableGZipOutput}');
|
|
|
|
|
|
|
|
putenv('TTRSS_PLUGINS=${builtins.concatStringsSep "," cfg.plugins}');
|
|
|
|
|
|
|
|
putenv('TTRSS_LOG_DESTINATION=${cfg.logDestination}');
|
|
|
|
putenv('TTRSS_CONFIG_VERSION=${toString configVersion}');
|
|
|
|
|
|
|
|
|
|
|
|
putenv('TTRSS_PUBSUBHUBBUB_ENABLED=${boolToString cfg.pubSubHubbub.enable}');
|
|
|
|
putenv('TTRSS_PUBSUBHUBBUB_HUB=${cfg.pubSubHubbub.hub}');
|
|
|
|
|
|
|
|
putenv('TTRSS_SPHINX_SERVER=${cfg.sphinx.server}');
|
|
|
|
putenv('TTRSS_SPHINX_INDEX=${builtins.concatStringsSep "," cfg.sphinx.index}');
|
|
|
|
|
|
|
|
putenv('TTRSS_ENABLE_REGISTRATION=${boolToString cfg.registration.enable}');
|
|
|
|
putenv('TTRSS_REG_NOTIFY_ADDRESS=${cfg.registration.notifyAddress}');
|
|
|
|
putenv('TTRSS_REG_MAX_USERS=${toString cfg.registration.maxUsers}');
|
|
|
|
|
|
|
|
putenv('TTRSS_SMTP_SERVER=${cfg.email.server}');
|
|
|
|
putenv('TTRSS_SMTP_LOGIN=${cfg.email.login}');
|
|
|
|
putenv('TTRSS_SMTP_PASSWORD=${escape ["'" "\\"] cfg.email.password}');
|
|
|
|
putenv('TTRSS_SMTP_SECURE=${cfg.email.security}');
|
|
|
|
|
|
|
|
putenv('TTRSS_SMTP_FROM_NAME=${escape ["'" "\\"] cfg.email.fromName}');
|
|
|
|
putenv('TTRSS_SMTP_FROM_ADDRESS=${escape ["'" "\\"] cfg.email.fromAddress}');
|
|
|
|
putenv('TTRSS_DIGEST_SUBJECT=${escape ["'" "\\"] cfg.email.digestSubject}');
|
2016-06-05 18:55:46 +00:00
|
|
|
|
2018-06-04 12:14:57 +00:00
|
|
|
${cfg.extraConfig}
|
2016-06-05 18:55:46 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-08 12:00:00 +00:00
|
|
|
# tt-rss and plugins and themes and config.php
|
|
|
|
servedRoot = pkgs.runCommand "tt-rss-served-root" {} ''
|
|
|
|
cp --no-preserve=mode -r ${pkgs.tt-rss} $out
|
|
|
|
cp ${tt-rss-config} $out/config.php
|
|
|
|
${optionalString (cfg.pluginPackages != []) ''
|
|
|
|
for plugin in ${concatStringsSep " " cfg.pluginPackages}; do
|
|
|
|
cp -r "$plugin"/* "$out/plugins.local/"
|
|
|
|
done
|
|
|
|
''}
|
|
|
|
${optionalString (cfg.themePackages != []) ''
|
|
|
|
for theme in ${concatStringsSep " " cfg.themePackages}; do
|
|
|
|
cp -r "$theme"/* "$out/themes.local/"
|
|
|
|
done
|
|
|
|
''}
|
|
|
|
'';
|
|
|
|
|
2016-06-05 18:55:46 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.tt-rss = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "tt-rss";
|
|
|
|
|
2016-08-27 19:08:32 +00:00
|
|
|
root = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/tt-rss";
|
|
|
|
description = ''
|
|
|
|
Root of the application.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-06-05 18:55:46 +00:00
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
2018-01-02 19:45:42 +00:00
|
|
|
default = "tt_rss";
|
2016-06-05 18:55:46 +00:00
|
|
|
description = ''
|
2016-08-27 19:10:30 +00:00
|
|
|
User account under which both the update daemon and the web-application run.
|
2016-06-05 18:55:46 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
pool = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${poolName}";
|
|
|
|
description = ''
|
|
|
|
Name of existing phpfpm pool that is used to run web-application.
|
|
|
|
If not specified a pool will be created automatically with
|
|
|
|
default values.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-08-27 19:20:28 +00:00
|
|
|
virtualHost = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = "tt-rss";
|
|
|
|
description = ''
|
|
|
|
Name of the nginx virtualhost to use and setup. If null, do not setup any virtualhost.
|
|
|
|
'';
|
|
|
|
};
|
2016-06-05 18:55:46 +00:00
|
|
|
|
|
|
|
database = {
|
|
|
|
type = mkOption {
|
|
|
|
type = types.enum ["pgsql" "mysql"];
|
|
|
|
default = "pgsql";
|
|
|
|
description = ''
|
|
|
|
Database to store feeds. Supported are pgsql and mysql.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
host = mkOption {
|
2016-08-27 19:18:04 +00:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2016-06-05 18:55:46 +00:00
|
|
|
description = ''
|
2016-08-27 19:18:04 +00:00
|
|
|
Host of the database. Leave null to use Unix domain socket.
|
2016-06-05 18:55:46 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "tt_rss";
|
|
|
|
description = ''
|
|
|
|
Name of the existing database.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "tt_rss";
|
|
|
|
description = ''
|
|
|
|
The database user. The user must exist and has access to
|
|
|
|
the specified database.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
password = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
The database user's password.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-09-30 11:06:07 +00:00
|
|
|
passwordFile = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
The database user's password.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-06-05 18:55:46 +00:00
|
|
|
port = mkOption {
|
2022-11-09 21:30:00 +00:00
|
|
|
type = types.nullOr types.port;
|
2016-06-05 18:55:46 +00:00
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
The database's port. If not set, the default ports will be provided (5432
|
|
|
|
and 3306 for pgsql and mysql respectively).
|
|
|
|
'';
|
|
|
|
};
|
2019-07-06 02:04:56 +00:00
|
|
|
|
|
|
|
createLocally = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Create the database and database user locally.";
|
|
|
|
};
|
2016-06-05 18:55:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auth = {
|
|
|
|
autoCreate = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Allow authentication modules to auto-create users in tt-rss internal
|
|
|
|
database when authenticated successfully.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
autoLogin = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Automatically login user on remote or other kind of externally supplied
|
|
|
|
authentication, otherwise redirect to login form as normal.
|
|
|
|
If set to true, users won't be able to set application language
|
|
|
|
and settings profile.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
pubSubHubbub = {
|
|
|
|
hub = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
URL to a PubSubHubbub-compatible hub server. If defined, "Published
|
|
|
|
articles" generated feed would automatically become PUSH-enabled.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enable client PubSubHubbub support in tt-rss. When disabled, tt-rss
|
|
|
|
won't try to subscribe to PUSH feed updates.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
sphinx = {
|
|
|
|
server = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "localhost:9312";
|
|
|
|
description = ''
|
|
|
|
Hostname:port combination for the Sphinx server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
index = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = ["ttrss" "delta"];
|
|
|
|
description = ''
|
|
|
|
Index names in Sphinx configuration. Example configuration
|
|
|
|
files are available on tt-rss wiki.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
registration = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Allow users to register themselves. Please be aware that allowing
|
|
|
|
random people to access your tt-rss installation is a security risk
|
|
|
|
and potentially might lead to data loss or server exploit. Disabled
|
|
|
|
by default.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
notifyAddress = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Email address to send new user notifications to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
maxUsers = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
|
|
|
description = ''
|
|
|
|
Maximum amount of users which will be allowed to register on this
|
|
|
|
system. 0 - no limit.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
email = {
|
|
|
|
server = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
example = "localhost:25";
|
|
|
|
description = ''
|
|
|
|
Hostname:port combination to send outgoing mail. Blank - use system
|
|
|
|
MTA.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
login = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
SMTP authentication login used when sending outgoing mail.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
password = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
SMTP authentication password used when sending outgoing mail.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
security = mkOption {
|
|
|
|
type = types.enum ["" "ssl" "tls"];
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Used to select a secure SMTP connection. Allowed values: ssl, tls,
|
|
|
|
or empty.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
fromName = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "Tiny Tiny RSS";
|
|
|
|
description = ''
|
|
|
|
Name for sending outgoing mail. This applies to password reset
|
|
|
|
notifications, digest emails and any other mail.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
fromAddress = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Address for sending outgoing mail. This applies to password reset
|
|
|
|
notifications, digest emails and any other mail.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
digestSubject = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "[tt-rss] New headlines for last 24 hours";
|
|
|
|
description = ''
|
|
|
|
Subject line for email digests.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
sessionCookieLifetime = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 86400;
|
|
|
|
description = ''
|
|
|
|
Default lifetime of a session (e.g. login) cookie. In seconds,
|
|
|
|
0 means cookie will be deleted when browser closes.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
selfUrlPath = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Full URL of your tt-rss installation. This should be set to the
|
|
|
|
location of tt-rss directory, e.g. http://example.org/tt-rss/
|
|
|
|
You need to set this option correctly otherwise several features
|
|
|
|
including PUSH, bookmarklets and browser integration will not work properly.
|
|
|
|
'';
|
|
|
|
example = "http://localhost";
|
|
|
|
};
|
|
|
|
|
|
|
|
feedCryptKey = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Key used for encryption of passwords for password-protected feeds
|
|
|
|
in the database. A string of 24 random characters. If left blank, encryption
|
|
|
|
is not used. Requires mcrypt functions.
|
|
|
|
Warning: changing this key will make your stored feed passwords impossible
|
|
|
|
to decrypt.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
singleUserMode = mkOption {
|
|
|
|
type = types.bool;
|
2016-08-27 19:23:19 +00:00
|
|
|
default = false;
|
2016-06-05 18:55:46 +00:00
|
|
|
|
|
|
|
description = ''
|
|
|
|
Operate in single user mode, disables all functionality related to
|
|
|
|
multiple users and authentication. Enabling this assumes you have
|
|
|
|
your tt-rss directory protected by other means (e.g. http auth).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
simpleUpdateMode = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enables fallback update mode where tt-rss tries to update feeds in
|
|
|
|
background while tt-rss is open in your browser.
|
|
|
|
If you don't have a lot of feeds and don't want to or can't run
|
|
|
|
background processes while not running tt-rss, this method is generally
|
|
|
|
viable to keep your feeds up to date.
|
|
|
|
Still, there are more robust (and recommended) updating methods
|
2023-10-30 20:41:44 +00:00
|
|
|
available, you can read about them here: <https://tt-rss.org/wiki/UpdatingFeeds>
|
2016-06-05 18:55:46 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
forceArticlePurge = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
|
|
|
description = ''
|
|
|
|
When this option is not 0, users ability to control feed purging
|
|
|
|
intervals is disabled and all articles (which are not starred)
|
|
|
|
older than this amount of days are purged.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableGZipOutput = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Selectively gzip output to improve wire performance. This requires
|
|
|
|
PHP Zlib extension on the server.
|
|
|
|
Enabling this can break tt-rss in several httpd/php configurations,
|
|
|
|
if you experience weird errors and tt-rss failing to start, blank pages
|
|
|
|
after login, or content encoding errors, disable it.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-12-27 16:03:51 +00:00
|
|
|
phpPackage = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
default = pkgs.php;
|
|
|
|
defaultText = "pkgs.php";
|
|
|
|
description = ''
|
|
|
|
php package to use for php fpm and update daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-06-05 18:55:46 +00:00
|
|
|
plugins = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = ["auth_internal" "note"];
|
|
|
|
description = ''
|
|
|
|
List of plugins to load automatically for all users.
|
|
|
|
System plugins have to be specified here. Please enable at least one
|
|
|
|
authentication plugin here (auth_*).
|
|
|
|
Users may enable other user plugins from Preferences/Plugins but may not
|
|
|
|
disable plugins specified in this list.
|
|
|
|
Disabling auth_internal in this list would automatically disable
|
|
|
|
reset password link on the login form.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-06-04 12:14:57 +00:00
|
|
|
pluginPackages = mkOption {
|
|
|
|
type = types.listOf types.package;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
List of plugins to install. The list elements are expected to
|
|
|
|
be derivations. All elements in this derivation are automatically
|
|
|
|
copied to the `plugins.local` directory.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
themePackages = mkOption {
|
|
|
|
type = types.listOf types.package;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
List of themes to install. The list elements are expected to
|
|
|
|
be derivations. All elements in this derivation are automatically
|
|
|
|
copied to the `themes.local` directory.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-06-05 18:55:46 +00:00
|
|
|
logDestination = mkOption {
|
|
|
|
type = types.enum ["" "sql" "syslog"];
|
|
|
|
default = "sql";
|
|
|
|
description = ''
|
|
|
|
Log destination to use. Possible values: sql (uses internal logging
|
|
|
|
you can read in Preferences -> System), syslog - logs to system log.
|
|
|
|
Setting this to blank uses PHP logging (usually to http server
|
|
|
|
error.log).
|
|
|
|
'';
|
|
|
|
};
|
2018-06-04 12:14:57 +00:00
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Additional lines to append to `config.php`.
|
|
|
|
'';
|
|
|
|
};
|
2016-06-05 18:55:46 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-02-06 04:44:48 +00:00
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule ["services" "tt-rss" "checkForUpdates"] ''
|
|
|
|
This option was removed because setting this to true will cause TT-RSS
|
|
|
|
to be unable to start if an automatic update of the code in
|
|
|
|
services.tt-rss.root leads to a database schema upgrade that is not
|
|
|
|
supported by the code active in the Nix store.
|
|
|
|
'')
|
|
|
|
];
|
2016-06-05 18:55:46 +00:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2016-08-27 19:08:32 +00:00
|
|
|
config = mkIf cfg.enable {
|
2016-06-05 18:55:46 +00:00
|
|
|
|
2018-09-30 11:06:07 +00:00
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = cfg.database.password != null -> cfg.database.passwordFile == null;
|
|
|
|
message = "Cannot set both password and passwordFile";
|
|
|
|
}
|
nixos/postgresql: drop ensurePermissions, fix ensureUsers for postgresql15
Closes #216989
First of all, a bit of context: in PostgreSQL, newly created users don't
have the CREATE privilege on the public schema of a database even with
`ALL PRIVILEGES` granted via `ensurePermissions` which is how most of
the DB users are currently set up "declaratively"[1]. This means e.g. a
freshly deployed Nextcloud service will break early because Nextcloud
itself cannot CREATE any tables in the public schema anymore.
The other issue here is that `ensurePermissions` is a mere hack. It's
effectively a mixture of SQL code (e.g. `DATABASE foo` is relying on how
a value is substituted in a query. You'd have to parse a subset of SQL
to actually know which object are permissions granted to for a user).
After analyzing the existing modules I realized that in every case with
a single exception[2] the UNIX system user is equal to the db user is
equal to the db name and I don't see a compelling reason why people
would change that in 99% of the cases. In fact, some modules would even
break if you'd change that because the declarations of the system user &
the db user are mixed up[3].
So I decided to go with something new which restricts the ways to use
`ensure*` options rather than expanding those[4]. Effectively this means
that
* The DB user _must_ be equal to the DB name.
* Permissions are granted via `ensureDBOwnerhip` for an attribute-set in
`ensureUsers`. That way, the user is actually the owner and can
perform `CREATE`.
* For such a postgres user, a database must be declared in
`ensureDatabases`.
For anything else, a custom state management should be implemented. This
can either be `initialScript`, doing it manual, outside of the module or
by implementing proper state management for postgresql[5], but the
current state of `ensure*` isn't even declarative, but a convergent tool
which is what Nix actually claims to _not_ do.
Regarding existing setups: there are effectively two options:
* Leave everything as-is (assuming that system user == db user == db
name): then the DB user will automatically become the DB owner and
everything else stays the same.
* Drop the `createDatabase = true;` declarations: nothing will change
because a removal of `ensure*` statements is ignored, so it doesn't
matter at all whether this option is kept after the first deploy (and
later on you'd usually restore from backups anyways).
The DB user isn't the owner of the DB then, but for an existing setup
this is irrelevant because CREATE on the public schema isn't revoked
from existing users (only not granted for new users).
[1] not really declarative though because removals of these statements
are simply ignored for instance: https://github.com/NixOS/nixpkgs/issues/206467
[2] `services.invidious`: I removed the `ensure*` part temporarily
because it IMHO falls into the category "manage the state on your
own" (see the commit message). See also
https://github.com/NixOS/nixpkgs/pull/265857
[3] e.g. roundcube had `"DATABASE ${cfg.database.username}" = "ALL PRIVILEGES";`
[4] As opposed to other changes that are considered a potential fix, but
also add more things like collation for DBs or passwords that are
_never_ touched again when changing those.
[5] As suggested in e.g. https://github.com/NixOS/nixpkgs/issues/206467
2023-11-08 11:50:09 +00:00
|
|
|
{
|
|
|
|
assertion = cfg.database.createLocally -> cfg.database.name == cfg.user && cfg.database.user == cfg.user;
|
|
|
|
message = ''
|
|
|
|
When creating a database via NixOS, the db user and db name must be equal!
|
|
|
|
If you already have an existing DB+user and this assertion is new, you can safely set
|
|
|
|
`services.tt-rss.database.createLocally` to `false` because removal of `ensureUsers`
|
|
|
|
and `ensureDatabases` doesn't have any effect.
|
|
|
|
'';
|
|
|
|
}
|
2018-09-30 11:06:07 +00:00
|
|
|
];
|
|
|
|
|
2018-10-14 12:27:30 +00:00
|
|
|
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
|
2019-09-08 23:38:31 +00:00
|
|
|
${poolName} = {
|
2019-08-08 02:36:49 +00:00
|
|
|
inherit (cfg) user;
|
2023-12-27 16:03:51 +00:00
|
|
|
inherit phpPackage;
|
2019-08-08 02:36:49 +00:00
|
|
|
settings = mapAttrs (name: mkDefault) {
|
|
|
|
"listen.owner" = "nginx";
|
|
|
|
"listen.group" = "nginx";
|
|
|
|
"listen.mode" = "0600";
|
|
|
|
"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;
|
|
|
|
};
|
2018-10-14 12:27:30 +00:00
|
|
|
};
|
2016-08-27 19:20:28 +00:00
|
|
|
};
|
|
|
|
|
2018-04-17 09:44:52 +00:00
|
|
|
# NOTE: No configuration is done if not using virtual host
|
|
|
|
services.nginx = mkIf (cfg.virtualHost != null) {
|
2018-01-02 19:48:00 +00:00
|
|
|
enable = true;
|
2018-04-17 09:44:52 +00:00
|
|
|
virtualHosts = {
|
2019-08-13 21:52:01 +00:00
|
|
|
${cfg.virtualHost} = {
|
2021-08-08 12:00:00 +00:00
|
|
|
root = "${cfg.root}/www";
|
2018-01-02 19:48:00 +00:00
|
|
|
|
|
|
|
locations."/" = {
|
|
|
|
index = "index.php";
|
|
|
|
};
|
|
|
|
|
2021-08-08 12:00:00 +00:00
|
|
|
locations."^~ /feed-icons" = {
|
|
|
|
root = "${cfg.root}";
|
|
|
|
};
|
|
|
|
|
2019-09-17 00:23:51 +00:00
|
|
|
locations."~ \\.php$" = {
|
2018-01-02 19:48:00 +00:00
|
|
|
extraConfig = ''
|
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
2019-07-03 21:34:17 +00:00
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.${cfg.pool}.socket};
|
2018-01-02 19:48:00 +00:00
|
|
|
fastcgi_index index.php;
|
|
|
|
'';
|
|
|
|
};
|
2016-08-27 19:20:28 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2016-06-05 18:55:46 +00:00
|
|
|
|
2019-07-06 02:04:56 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
2021-08-08 12:00:00 +00:00
|
|
|
"d '${cfg.root}' 0555 ${cfg.user} tt_rss - -"
|
|
|
|
"d '${cfg.root}/lock' 0755 ${cfg.user} tt_rss - -"
|
|
|
|
"d '${cfg.root}/cache' 0755 ${cfg.user} tt_rss - -"
|
|
|
|
"d '${cfg.root}/cache/upload' 0755 ${cfg.user} tt_rss - -"
|
|
|
|
"d '${cfg.root}/cache/images' 0755 ${cfg.user} tt_rss - -"
|
|
|
|
"d '${cfg.root}/cache/export' 0755 ${cfg.user} tt_rss - -"
|
|
|
|
"d '${cfg.root}/feed-icons' 0755 ${cfg.user} tt_rss - -"
|
|
|
|
"L+ '${cfg.root}/www' - - - - ${servedRoot}"
|
2019-07-06 02:04:56 +00:00
|
|
|
];
|
|
|
|
|
2021-07-25 19:40:33 +00:00
|
|
|
systemd.services = {
|
|
|
|
phpfpm-tt-rss = mkIf (cfg.pool == "${poolName}") {
|
2021-08-08 12:00:00 +00:00
|
|
|
restartTriggers = [ servedRoot ];
|
2021-07-25 19:40:33 +00:00
|
|
|
};
|
2016-06-05 18:55:46 +00:00
|
|
|
|
2021-07-25 19:40:33 +00:00
|
|
|
tt-rss = {
|
2016-06-05 18:55:46 +00:00
|
|
|
description = "Tiny Tiny RSS feeds update daemon";
|
|
|
|
|
2023-08-29 22:04:56 +00:00
|
|
|
preStart = ''
|
2023-12-27 16:03:51 +00:00
|
|
|
${phpPackage}/bin/php ${cfg.root}/www/update.php --update-schema --force-yes
|
2023-08-29 22:04:56 +00:00
|
|
|
'';
|
2016-06-05 18:55:46 +00:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = "${cfg.user}";
|
2019-07-06 02:04:56 +00:00
|
|
|
Group = "tt_rss";
|
2023-12-27 16:03:51 +00:00
|
|
|
ExecStart = "${phpPackage}/bin/php ${cfg.root}/www/update.php --daemon --quiet";
|
2020-05-08 12:00:00 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSec = "60";
|
2020-05-08 12:00:00 +00:00
|
|
|
SyslogIdentifier = "tt-rss";
|
2016-06-05 18:55:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2019-07-06 02:04:56 +00:00
|
|
|
requires = optional mysqlLocal "mysql.service" ++ optional pgsqlLocal "postgresql.service";
|
|
|
|
after = [ "network.target" ] ++ optional mysqlLocal "mysql.service" ++ optional pgsqlLocal "postgresql.service";
|
2021-07-25 19:40:33 +00:00
|
|
|
};
|
2016-06-05 18:55:46 +00:00
|
|
|
};
|
2018-01-02 19:45:42 +00:00
|
|
|
|
2019-07-06 02:04:56 +00:00
|
|
|
services.mysql = mkIf mysqlLocal {
|
2018-01-02 19:48:40 +00:00
|
|
|
enable = true;
|
2021-06-04 14:08:41 +00:00
|
|
|
package = mkDefault pkgs.mariadb;
|
2018-01-02 19:48:40 +00:00
|
|
|
ensureDatabases = [ cfg.database.name ];
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = cfg.user;
|
|
|
|
ensurePermissions = {
|
|
|
|
"${cfg.database.name}.*" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2019-07-06 02:04:56 +00:00
|
|
|
services.postgresql = mkIf pgsqlLocal {
|
2018-01-05 13:17:35 +00:00
|
|
|
enable = mkDefault true;
|
2019-07-06 02:04:56 +00:00
|
|
|
ensureDatabases = [ cfg.database.name ];
|
|
|
|
ensureUsers = [
|
nixos/postgresql: drop ensurePermissions, fix ensureUsers for postgresql15
Closes #216989
First of all, a bit of context: in PostgreSQL, newly created users don't
have the CREATE privilege on the public schema of a database even with
`ALL PRIVILEGES` granted via `ensurePermissions` which is how most of
the DB users are currently set up "declaratively"[1]. This means e.g. a
freshly deployed Nextcloud service will break early because Nextcloud
itself cannot CREATE any tables in the public schema anymore.
The other issue here is that `ensurePermissions` is a mere hack. It's
effectively a mixture of SQL code (e.g. `DATABASE foo` is relying on how
a value is substituted in a query. You'd have to parse a subset of SQL
to actually know which object are permissions granted to for a user).
After analyzing the existing modules I realized that in every case with
a single exception[2] the UNIX system user is equal to the db user is
equal to the db name and I don't see a compelling reason why people
would change that in 99% of the cases. In fact, some modules would even
break if you'd change that because the declarations of the system user &
the db user are mixed up[3].
So I decided to go with something new which restricts the ways to use
`ensure*` options rather than expanding those[4]. Effectively this means
that
* The DB user _must_ be equal to the DB name.
* Permissions are granted via `ensureDBOwnerhip` for an attribute-set in
`ensureUsers`. That way, the user is actually the owner and can
perform `CREATE`.
* For such a postgres user, a database must be declared in
`ensureDatabases`.
For anything else, a custom state management should be implemented. This
can either be `initialScript`, doing it manual, outside of the module or
by implementing proper state management for postgresql[5], but the
current state of `ensure*` isn't even declarative, but a convergent tool
which is what Nix actually claims to _not_ do.
Regarding existing setups: there are effectively two options:
* Leave everything as-is (assuming that system user == db user == db
name): then the DB user will automatically become the DB owner and
everything else stays the same.
* Drop the `createDatabase = true;` declarations: nothing will change
because a removal of `ensure*` statements is ignored, so it doesn't
matter at all whether this option is kept after the first deploy (and
later on you'd usually restore from backups anyways).
The DB user isn't the owner of the DB then, but for an existing setup
this is irrelevant because CREATE on the public schema isn't revoked
from existing users (only not granted for new users).
[1] not really declarative though because removals of these statements
are simply ignored for instance: https://github.com/NixOS/nixpkgs/issues/206467
[2] `services.invidious`: I removed the `ensure*` part temporarily
because it IMHO falls into the category "manage the state on your
own" (see the commit message). See also
https://github.com/NixOS/nixpkgs/pull/265857
[3] e.g. roundcube had `"DATABASE ${cfg.database.username}" = "ALL PRIVILEGES";`
[4] As opposed to other changes that are considered a potential fix, but
also add more things like collation for DBs or passwords that are
_never_ touched again when changing those.
[5] As suggested in e.g. https://github.com/NixOS/nixpkgs/issues/206467
2023-11-08 11:50:09 +00:00
|
|
|
{ name = cfg.database.user;
|
|
|
|
ensureDBOwnership = true;
|
2019-07-06 02:04:56 +00:00
|
|
|
}
|
|
|
|
];
|
2018-01-02 19:45:42 +00:00
|
|
|
};
|
|
|
|
|
2019-07-06 02:04:56 +00:00
|
|
|
users.users.tt_rss = optionalAttrs (cfg.user == "tt_rss") {
|
|
|
|
description = "tt-rss service user";
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "tt_rss";
|
2018-01-05 13:17:35 +00:00
|
|
|
};
|
2019-07-06 02:04:56 +00:00
|
|
|
|
|
|
|
users.groups.tt_rss = {};
|
2016-06-05 18:55:46 +00:00
|
|
|
};
|
|
|
|
}
|