aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/tools/tools/grocy.nix
blob: 3c33170a4c8200b5c746ecb4faeaed8caa40945f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ lib, stdenv, grocy }:
rec {
  backups = {
    rootDir = varDir;
  };
  varDir = "/var/lib/grocy";
  activationScript = {
    deps = [ "wrappers" ];
    text = ''
      install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}/data
      install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
    '';
  };
  webRoot = grocy.webRoot;
  apache = rec {
    user = "wwwrun";
    group = "wwwrun";
    modules = [ "proxy_fcgi" ];
    root = webRoot;
    vhostConf = socket: ''
      Alias /grocy "${root}"
      <Directory "${root}">
        DirectoryIndex index.php
        <FilesMatch "\.php$">
          SetHandler "proxy:unix:${socket}|fcgi://localhost"
        </FilesMatch>

        AllowOverride All
        Options +FollowSymlinks
        Require all granted
      </Directory>
      '';
  };
  phpFpm = rec {
    basedir = builtins.concatStringsSep ":" (
      [ grocy grocy.yarnModules varDir ]);
    pool = {
      "listen.owner" = apache.user;
      "listen.group" = apache.group;
      "pm" = "ondemand";
      "pm.max_children" = "60";
      "pm.process_idle_timeout" = "60";

      # Needed to avoid clashes in browser cookies (same domain)
      "php_value[session.name]" = "grocyPHPSESSID";
      "php_admin_value[open_basedir]" = "${basedir}:/tmp";
      "php_admin_value[session.save_path]" = "${varDir}/phpSessions";
    };
  };
}