]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - virtual/modules/websites/commons/adminer.nix
7094e455d098d811ffc26eb0cb8417582a1c9ecb
[perso/Immae/Config/Nix.git] / virtual / modules / websites / commons / adminer.nix
1 { stdenv, fetchurl, nginx }:
2 let
3 adminer = rec {
4 webRoot = stdenv.mkDerivation rec {
5 version = "4.7.0";
6 name = "adminer-${version}";
7 src = fetchurl {
8 url = "https://www.adminer.org/static/download/${version}/${name}.php";
9 sha256 = "1qq2g7rbfh2vrqfm3g0bz0qs057b049n0mhabnsbd1sgnpvnc5z7";
10 };
11 phases = "installPhase";
12 installPhase = ''
13 mkdir -p $out
14 cp $src $out/index.php
15 '';
16 };
17 phpFpm = rec {
18 socket = "/var/run/phpfpm/adminer.sock";
19 pool = ''
20 listen = ${socket}
21 user = ${apache.user}
22 group = ${apache.group}
23 listen.owner = ${apache.user}
24 listen.group = ${apache.group}
25 pm = ondemand
26 pm.max_children = 5
27 pm.process_idle_timeout = 60
28 ;php_admin_flag[log_errors] = on
29 ; Needed to avoid clashes in browser cookies (same domain)
30 php_value[session.name] = AdminerPHPSESSID
31 php_admin_value[open_basedir] = "${webRoot}:/tmp"
32 php_admin_value[session.save_path] = "/var/lib/php/sessions/adminer"
33 '';
34 };
35 apache = {
36 user = "wwwrun";
37 group = "wwwrun";
38 modules = [ "proxy_fcgi" ];
39 vhostConf = ''
40 Alias /adminer ${webRoot}
41 <Directory ${webRoot}>
42 DirectoryIndex index.php
43 <FilesMatch "\.php$">
44 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
45 </FilesMatch>
46 </Directory>
47 '';
48 };
49 nginxConf = {
50 alias = webRoot;
51 index = "index.php";
52 extraConfig = ''
53 include ${nginx}/conf/fastcgi.conf;
54 fastcgi_split_path_info ^(.+?\.php)(/.*)$;
55 fastcgi_param HTTP_PROXY "";
56 fastcgi_param SCRIPT_FILENAME ${webRoot}/index.php;
57 fastcgi_pass unix:${phpFpm.socket};
58 fastcgi_index index.php;
59 fastcgi_intercept_errors on;
60 '';
61 };
62 };
63 in
64 adminer