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