]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/tools/tools/grocy.nix
1b8da20414bfdaa64a07e155d4173d200d4bf6b5
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / tools / grocy.nix
1 { lib, stdenv, grocy }:
2 rec {
3 backups = {
4 rootDir = varDir;
5 };
6 varDir = "/var/lib/grocy";
7 activationScript = {
8 deps = [ "wrappers" ];
9 text = ''
10 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}/data
11 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
12 '';
13 };
14 webRoot = grocy.webRoot;
15 apache = rec {
16 user = "wwwrun";
17 group = "wwwrun";
18 modules = [ "proxy_fcgi" ];
19 webappName = "tools_grocy";
20 root = "/run/current-system/webapps/${webappName}";
21 vhostConf = ''
22 Alias /grocy "${root}"
23 <Directory "${root}">
24 DirectoryIndex index.php
25 <FilesMatch "\.php$">
26 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
27 </FilesMatch>
28
29 AllowOverride All
30 Options +FollowSymlinks
31 Require all granted
32 </Directory>
33 '';
34 };
35 phpFpm = rec {
36 basedir = builtins.concatStringsSep ":" (
37 [ grocy grocy.yarnModules varDir ]);
38 socket = "/var/run/phpfpm/grocy.sock";
39 pool = ''
40 user = ${apache.user}
41 group = ${apache.group}
42 listen.owner = ${apache.user}
43 listen.group = ${apache.group}
44 pm = ondemand
45 pm.max_children = 60
46 pm.process_idle_timeout = 60
47
48 ; Needed to avoid clashes in browser cookies (same domain)
49 php_value[session.name] = grocyPHPSESSID
50 php_admin_value[open_basedir] = "${basedir}:/tmp"
51 php_admin_value[session.save_path] = "${varDir}/phpSessions"
52 '';
53 };
54 }
55