aboutsummaryrefslogtreecommitdiff
path: root/systems/eldiron/websites/tools/wallabag.nix
diff options
context:
space:
mode:
Diffstat (limited to 'systems/eldiron/websites/tools/wallabag.nix')
-rw-r--r--systems/eldiron/websites/tools/wallabag.nix180
1 files changed, 180 insertions, 0 deletions
diff --git a/systems/eldiron/websites/tools/wallabag.nix b/systems/eldiron/websites/tools/wallabag.nix
new file mode 100644
index 0000000..0a5750d
--- /dev/null
+++ b/systems/eldiron/websites/tools/wallabag.nix
@@ -0,0 +1,180 @@
1{ env, wallabag, mylibs, config }:
2rec {
3 varDir = "/var/lib/wallabag";
4 keys."webapps/tools-wallabag" = {
5 user = apache.user;
6 group = apache.group;
7 permissions = "0400";
8 text = ''
9 # This file is auto-generated during the composer install
10 parameters:
11 database_driver: pdo_pgsql
12 database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver
13 database_host: ${env.postgresql.socket}
14 database_port: ${env.postgresql.port}
15 database_name: ${env.postgresql.database}
16 database_user: ${env.postgresql.user}
17 database_password: ${env.postgresql.password}
18 database_path: null
19 database_table_prefix: wallabag_
20 database_socket: null
21 database_charset: utf8
22 domain_name: https://tools.immae.eu/wallabag
23 mailer_transport: sendmail
24 mailer_host: 127.0.0.1
25 mailer_user: null
26 mailer_password: null
27 locale: fr
28 secret: ${env.secret}
29 twofactor_auth: true
30 twofactor_sender: wallabag@tools.immae.eu
31 fosuser_registration: false
32 fosuser_confirmation: true
33 from_email: wallabag@tools.immae.eu
34 rss_limit: 50
35 rabbitmq_host: localhost
36 rabbitmq_port: 5672
37 rabbitmq_user: guest
38 rabbitmq_password: guest
39 rabbitmq_prefetch_count: 10
40 redis_scheme: unix
41 redis_host: null
42 redis_port: null
43 redis_path: ${env.redis.socket}
44 redis_password: null
45 sites_credentials: { }
46 ldap_enabled: true
47 ldap_host: ${env.ldap.host}
48 ldap_port: 636
49 ldap_tls: false
50 ldap_ssl: true
51 ldap_bind_requires_dn: true
52 ldap_base: '${env.ldap.base}'
53 ldap_manager_dn: '${env.ldap.dn}'
54 ldap_manager_pw: ${env.ldap.password}
55 ldap_filter: '${env.ldap.filter}'
56 ldap_admin_filter: '${env.ldap.admin_filter}'
57 ldap_username_attribute: uid
58 ldap_email_attribute: mail
59 ldap_name_attribute: cn
60 ldap_enabled_attribute: null
61 services:
62 swiftmailer.mailer.default.transport:
63 class: Swift_SendmailTransport
64 arguments: ['/run/wrappers/bin/sendmail -bs']
65 '';
66 };
67 chatonsProperties = {
68 file.datetime = "2022-08-21T22:50:00";
69 service = {
70 name = "Wallabag";
71 description = "wallabag is a self hostable application for saving web pages: Save and classify articles. Read them later. Freely.";
72 website = "https://tools.immae.eu/wallabag/";
73 logo = "https://tools.immae.eu/wallabag/wallassets/themes/_global/img/appicon/apple-touch-icon-120.png";
74 status.level = "OK";
75 status.description = "OK";
76 registration."" = ["MEMBER" "CLIENT"];
77 registration.load = "OPEN";
78 install.type = "PACKAGE";
79 };
80 software = {
81 name = "Wallabag";
82 website = "https://wallabag.org/en";
83 license.url = "https://github.com/wallabag/wallabag/blob/master/COPYING.md";
84 license.name = "MIT License";
85 version = webappDir.version;
86 source.url = "https://github.com/wallabag/wallabag";
87 modules = "ldap-patch";
88 };
89 };
90 webappDir = wallabag.override { ldap = true; wallabag_config = config.secrets.fullPaths."webapps/tools-wallabag"; };
91 activationScript = ''
92 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
93 ${varDir}/var ${varDir}/data/db ${varDir}/assets/images
94 '';
95 webRoot = "${webappDir}/web";
96 # Domain migration: Table wallabag_entry contains whole
97 # https://tools.immae.eu/wallabag domain name in preview_picture
98 apache = rec {
99 user = "wwwrun";
100 group = "wwwrun";
101 modules = [ "proxy_fcgi" ];
102 root = webRoot;
103 vhostConf = socket: ''
104 Alias /wallabag "${root}"
105 <Directory "${root}">
106 AllowOverride None
107 Require all granted
108 # For OAuth (apps)
109 CGIPassAuth On
110
111 <FilesMatch "\.php$">
112 SetHandler "proxy:unix:${socket}|fcgi://localhost"
113 </FilesMatch>
114
115 <IfModule mod_rewrite.c>
116 Options -MultiViews
117 RewriteEngine On
118 RewriteCond %{REQUEST_FILENAME} !-f
119 RewriteRule ^(.*)$ app.php [QSA,L]
120 </IfModule>
121 </Directory>
122 <Directory "${root}/bundles">
123 <IfModule mod_rewrite.c>
124 RewriteEngine Off
125 </IfModule>
126 </Directory>
127 <Directory "${varDir}/assets">
128 AllowOverride None
129 Require all granted
130 </Directory>
131 '';
132 };
133 phpFpm = rec {
134 preStart = ''
135 if [ ! -f "${varDir}/currentWebappDir" -o \
136 ! -f "${varDir}/currentKey" -o \
137 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \
138 || ! sha512sum -c --status ${varDir}/currentKey; then
139 pushd ${webappDir} > /dev/null
140 /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod cache:clear
141 rm -rf /var/lib/wallabag/var/cache/pro_
142 /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction
143 popd > /dev/null
144 echo -n "${webappDir}" > ${varDir}/currentWebappDir
145 sha512sum ${config.secrets.fullPaths."webapps/tools-wallabag"} > ${varDir}/currentKey
146 fi
147 '';
148 serviceDeps = [ "postgresql.service" "openldap.service" ];
149 basedir = builtins.concatStringsSep ":" [ webappDir config.secrets.fullPaths."webapps/tools-wallabag" varDir ];
150 pool = {
151 "listen.owner" = apache.user;
152 "listen.group" = apache.group;
153 "pm" = "dynamic";
154 "pm.max_children" = "60";
155 "pm.start_servers" = "2";
156 "pm.min_spare_servers" = "1";
157 "pm.max_spare_servers" = "10";
158
159 # Needed to avoid clashes in browser cookies (same domain)
160 "php_value[session.name]" = "WallabagPHPSESSID";
161 "php_admin_value[session.save_handler]" = "redis";
162 "php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=Tools:Wallabag:'";
163 "php_admin_value[open_basedir]" = "/run/wrappers/bin/sendmail:${basedir}:/tmp";
164 "php_value[max_execution_time]" = "300";
165 };
166 };
167 monitoringPlugins = [ "http" ];
168 monitoringObjects.service = [
169 {
170 service_description = "wallabag website is running on tools.immae.eu";
171 host_name = config.hostEnv.fqdn;
172 use = "external-web-service";
173 check_command = ["check_https" "tools.immae.eu" "/wallabag/" "<title>Bienvenue sur wallabag"];
174
175 servicegroups = "webstatus-webapps";
176 _webstatus_name = "Wallabag";
177 _webstatus_url = "https://tools.immae.eu/wallabag/";
178 }
179 ];
180}