]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/tools/tools/ttrss.nix
Update richie website
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / tools / ttrss.nix
1 { php, env, ttrss, ttrss-plugins }:
2 rec {
3 backups = {
4 rootDir = varDir;
5 };
6 varDir = "/var/lib/ttrss";
7 activationScript = {
8 deps = [ "wrappers" ];
9 text = ''
10 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
11 ${varDir}/lock ${varDir}/cache ${varDir}/feed-icons
12 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}/cache/export/ \
13 ${varDir}/cache/feeds/ \
14 ${varDir}/cache/images/ \
15 ${varDir}/cache/js/ \
16 ${varDir}/cache/simplepie/ \
17 ${varDir}/cache/upload/
18 touch ${varDir}/feed-icons/index.html
19 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
20 '';
21 };
22 keys = [{
23 dest = "webapps/tools-ttrss";
24 user = apache.user;
25 group = apache.group;
26 permissions = "0400";
27 text = ''
28 <?php
29
30 define('PHP_EXECUTABLE', '${php}/bin/php');
31
32 define('LOCK_DIRECTORY', 'lock');
33 define('CACHE_DIR', 'cache');
34 define('ICONS_DIR', 'feed-icons');
35 define('ICONS_URL', 'feed-icons');
36 define('SELF_URL_PATH', 'https://tools.immae.eu/ttrss/');
37
38 define('MYSQL_CHARSET', 'UTF8');
39
40 define('DB_TYPE', 'pgsql');
41 define('DB_HOST', '${env.postgresql.socket}');
42 define('DB_USER', '${env.postgresql.user}');
43 define('DB_NAME', '${env.postgresql.database}');
44 define('DB_PASS', '${env.postgresql.password}');
45 define('DB_PORT', '${env.postgresql.port}');
46
47 define('AUTH_AUTO_CREATE', true);
48 define('AUTH_AUTO_LOGIN', true);
49
50 define('SINGLE_USER_MODE', false);
51
52 define('SIMPLE_UPDATE_MODE', false);
53 define('CHECK_FOR_UPDATES', true);
54
55 define('FORCE_ARTICLE_PURGE', 0);
56 define('SESSION_COOKIE_LIFETIME', 60*60*24*120);
57 define('ENABLE_GZIP_OUTPUT', false);
58
59 define('PLUGINS', 'auth_ldap, note, instances');
60
61 define('LOG_DESTINATION', ''');
62 define('CONFIG_VERSION', 26);
63
64
65 define('SPHINX_SERVER', 'localhost:9312');
66 define('SPHINX_INDEX', 'ttrss, delta');
67
68 define('ENABLE_REGISTRATION', false);
69 define('REG_NOTIFY_ADDRESS', 'ttrss@tools.immae.eu');
70 define('REG_MAX_USERS', 10);
71
72 define('SMTP_FROM_NAME', 'Tiny Tiny RSS');
73 define('SMTP_FROM_ADDRESS', 'ttrss@tools.immae.eu');
74 define('DIGEST_SUBJECT', '[tt-rss] New headlines for last 24 hours');
75
76 define('LDAP_AUTH_SERVER_URI', 'ldap://${env.ldap.host}:389/');
77 define('LDAP_AUTH_USETLS', TRUE);
78 define('LDAP_AUTH_ALLOW_UNTRUSTED_CERT', TRUE);
79 define('LDAP_AUTH_BASEDN', '${env.ldap.base}');
80 define('LDAP_AUTH_ANONYMOUSBEFOREBIND', FALSE);
81 define('LDAP_AUTH_SEARCHFILTER', '${env.ldap.filter}');
82
83 define('LDAP_AUTH_BINDDN', '${env.ldap.dn}');
84 define('LDAP_AUTH_BINDPW', '${env.ldap.password}');
85 define('LDAP_AUTH_LOGIN_ATTRIB', 'immaeTtrssLogin');
86
87 define('LDAP_AUTH_LOG_ATTEMPTS', FALSE);
88 define('LDAP_AUTH_DEBUG', FALSE);
89 '';
90 }];
91 webRoot = (ttrss.override { ttrss_config = "/var/secrets/webapps/tools-ttrss"; }).withPlugins (builtins.attrValues ttrss-plugins);
92 apache = rec {
93 user = "wwwrun";
94 group = "wwwrun";
95 modules = [ "proxy_fcgi" ];
96 webappName = "tools_ttrss";
97 root = "/run/current-system/webapps/${webappName}";
98 vhostConf = ''
99 Alias /ttrss "${root}"
100 <Directory "${root}">
101 DirectoryIndex index.php
102 <FilesMatch "\.php$">
103 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
104 </FilesMatch>
105
106 AllowOverride All
107 Options FollowSymlinks
108 Require all granted
109 </Directory>
110 '';
111 };
112 phpFpm = rec {
113 serviceDeps = [ "postgresql.service" "openldap.service" ];
114 basedir = builtins.concatStringsSep ":" (
115 [ webRoot "/var/secrets/webapps/tools-ttrss" varDir ]
116 ++ webRoot.plugins);
117 socket = "/var/run/phpfpm/ttrss.sock";
118 pool = ''
119 listen = ${socket}
120 user = ${apache.user}
121 group = ${apache.group}
122 listen.owner = ${apache.user}
123 listen.group = ${apache.group}
124 pm = ondemand
125 pm.max_children = 60
126 pm.process_idle_timeout = 60
127
128 ; Needed to avoid clashes in browser cookies (same domain)
129 php_value[session.name] = TtrssPHPSESSID
130 php_admin_value[open_basedir] = "${basedir}:/tmp"
131 php_admin_value[session.save_path] = "${varDir}/phpSessions"
132 '';
133 };
134 }