]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/modules/websites/tools/tools/shaarli.nix
9f3779f56e68c2aaa5e76601adf138f37146e401
[perso/Immae/Config/Nix.git] / nixops / modules / websites / tools / tools / shaarli.nix
1 { lib, env, stdenv, fetchurl }:
2
3 let
4 varDir = "/var/lib/shaarli";
5 shaarli = stdenv.mkDerivation rec {
6 name = "shaarli-${version}";
7 version = "0.10.2";
8
9 src = fetchurl {
10 url = "https://github.com/shaarli/Shaarli/releases/download/v${version}/shaarli-v${version}-full.tar.gz";
11 sha256 = "0h8sspj7siy3vgpi2i3gdrjcr5935fr4dfwq2zwd70sjx2sh9s78";
12 };
13
14 outputs = [ "out" "doc" ];
15
16 patches = [ ./shaarli_ldap.patch ];
17
18 installPhase = ''
19 rm -r {cache,pagecache,tmp,data}/
20 ln -sf ../../../..${varDir}/{cache,pagecache,tmp,data} .
21 mkdir -p $doc/share/doc
22 mv doc/ $doc/share/doc/shaarli
23 mkdir $out/
24 cp -R ./* $out
25 cp .htaccess $out/
26 '';
27
28 meta = with stdenv.lib; {
29 description = "The personal, minimalist, super-fast, database free, bookmarking service";
30 license = licenses.gpl3Plus;
31 homepage = https://github.com/shaarli/Shaarli;
32 maintainers = with maintainers; [ schneefux ];
33 platforms = platforms.all;
34 };
35 };
36 in rec {
37 activationScript = ''
38 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
39 ${varDir}/cache ${varDir}/pagecache ${varDir}/tmp ${varDir}/data \
40 ${varDir}/phpSessions
41 '';
42 webRoot = shaarli;
43 apache = {
44 user = "wwwrun";
45 group = "wwwrun";
46 modules = [ "proxy_fcgi" "rewrite" "env" ];
47 vhostConf = ''
48 Alias /Shaarli "${webRoot}"
49
50 <Directory "${webRoot}">
51 SetEnv SHAARLI_LDAP_PASSWORD "${env.ldap.password}"
52 SetEnv SHAARLI_LDAP_DN "${env.ldap.dn}"
53 SetEnv SHAARLI_LDAP_HOST "ldaps://${env.ldap.host}"
54 SetEnv SHAARLI_LDAP_BASE "${env.ldap.base}"
55 SetEnv SHAARLI_LDAP_FILTER "${env.ldap.search}"
56
57 DirectoryIndex index.php index.htm index.html
58 Options Indexes FollowSymLinks MultiViews Includes
59 AllowOverride All
60 Require all granted
61 <FilesMatch "\.php$">
62 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
63 </FilesMatch>
64 </Directory>
65 '';
66 };
67 phpFpm = rec {
68 basedir = builtins.concatStringsSep ":" [ webRoot varDir ];
69 socket = "/var/run/phpfpm/shaarli.sock";
70 pool = ''
71 listen = ${socket}
72 user = ${apache.user}
73 group = ${apache.group}
74 listen.owner = ${apache.user}
75 listen.group = ${apache.group}
76 pm = ondemand
77 pm.max_children = 60
78 pm.process_idle_timeout = 60
79
80 ; Needed to avoid clashes in browser cookies (same domain)
81 php_value[session.name] = ShaarliPHPSESSID
82 php_admin_value[open_basedir] = "${basedir}:/tmp"
83 php_admin_value[session.save_path] = "${varDir}/phpSessions"
84 '';
85 };
86 }