]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/tools/tools/shaarli.nix
Use attrs for secrets instead of lists
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / tools / shaarli.nix
1 { lib, env, stdenv, fetchurl, shaarli, config }:
2 let
3 varDir = "/var/lib/shaarli";
4 in rec {
5 backups = {
6 rootDir = varDir;
7 remotes = [ "eriomem" "ovh" ];
8 };
9 activationScript = ''
10 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
11 ${varDir}/cache ${varDir}/pagecache ${varDir}/tmp ${varDir}/data \
12 ${varDir}/phpSessions
13 '';
14 webRoot = shaarli varDir;
15 apache = rec {
16 user = "wwwrun";
17 group = "wwwrun";
18 modules = [ "proxy_fcgi" "rewrite" "env" ];
19 webappName = "tools_shaarli";
20 root = "/run/current-system/webapps/${webappName}";
21 vhostConf = socket: ''
22 Alias /Shaarli "${root}"
23
24 Include ${config.secrets.fullPaths."webapps/tools-shaarli"}
25 <Location /Shaarli>
26 Header set Access-Control-Allow-Origin "*"
27 Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
28 Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization, Client-Security-Token, Accept-Encoding"
29 </Location>
30 <Directory "${root}">
31 DirectoryIndex index.php index.htm index.html
32 Options Indexes FollowSymLinks MultiViews Includes
33 AllowOverride All
34 Require all granted
35 <FilesMatch "\.php$">
36 SetHandler "proxy:unix:${socket}|fcgi://localhost"
37 </FilesMatch>
38 </Directory>
39 '';
40 };
41 keys."webapps/tools-shaarli" = {
42 user = apache.user;
43 group = apache.group;
44 permissions = "0400";
45 text = ''
46 SetEnv SHAARLI_LDAP_PASSWORD "${env.ldap.password}"
47 SetEnv SHAARLI_LDAP_DN "${env.ldap.dn}"
48 SetEnv SHAARLI_LDAP_HOST "ldaps://${env.ldap.host}"
49 SetEnv SHAARLI_LDAP_BASE "${env.ldap.base}"
50 SetEnv SHAARLI_LDAP_FILTER "${env.ldap.filter}"
51 '';
52 };
53 phpFpm = rec {
54 serviceDeps = [ "openldap.service" ];
55 basedir = builtins.concatStringsSep ":" [ webRoot varDir ];
56 pool = {
57 "listen.owner" = apache.user;
58 "listen.group" = apache.group;
59 "pm" = "ondemand";
60 "pm.max_children" = "60";
61 "pm.process_idle_timeout" = "60";
62
63 # Needed to avoid clashes in browser cookies (same domain)
64 "php_value[session.name]" = "ShaarliPHPSESSID";
65 "php_admin_value[open_basedir]" = "${basedir}:/tmp";
66 "php_admin_value[session.save_path]" = "${varDir}/phpSessions";
67 "php_admin_value[upload_max_filesize]" = "200M";
68 "php_admin_value[post_max_size]" = "200M";
69 };
70 };
71 }