]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - virtual/packages.nix
Move nixpkgs import to libs
[perso/Immae/Config/Nix.git] / virtual / packages.nix
1 with import ../libs.nix;
2 with nixpkgs_unstable;
3 let
4 adminer = rec {
5 webRoot = pkgs.stdenv.mkDerivation rec {
6 version = "4.7.0";
7 name = "adminer-${version}";
8 src = pkgs.fetchurl {
9 url = "https://www.adminer.org/static/download/${version}/${name}.php";
10 sha256 = "1qq2g7rbfh2vrqfm3g0bz0qs057b049n0mhabnsbd1sgnpvnc5z7";
11 };
12 phases = "installPhase";
13 installPhase = ''
14 mkdir -p $out
15 cp $src $out/index.php
16 '';
17 };
18 phpFpm = rec {
19 socket = "/var/run/phpfpm/adminer.sock";
20 pool = ''
21 listen = ${socket}
22 user = ${apache.user}
23 group = ${apache.group}
24 listen.owner = ${apache.user}
25 listen.group = ${apache.group}
26 pm = ondemand
27 pm.max_children = 5
28 pm.process_idle_timeout = 60
29 ;php_admin_flag[log_errors] = on
30 php_admin_value[open_basedir] = "${webRoot}:/tmp"
31 '';
32 };
33 apache = {
34 user = "wwwrun";
35 group = "wwwrun";
36 modules = [ "proxy_fcgi" ];
37 vhostConf = ''
38 Alias /adminer ${webRoot}
39 <Directory ${webRoot}>
40 DirectoryIndex = index.php
41 <FilesMatch "\.php$">
42 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
43 </FilesMatch>
44 </Directory>
45 '';
46 };
47 nginxConf = {
48 alias = webRoot;
49 index = "index.php";
50 extraConfig = ''
51 include ${pkgs.nginx}/conf/fastcgi.conf;
52 fastcgi_split_path_info ^(.+?\.php)(/.*)$;
53 fastcgi_param HTTP_PROXY "";
54 fastcgi_param SCRIPT_FILENAME ${webRoot}/index.php;
55 fastcgi_pass unix:${phpFpm.socket};
56 fastcgi_index index.php;
57 fastcgi_intercept_errors on;
58 '';
59 };
60 };
61
62 ympd = rec {
63 config = {
64 webPort = "localhost:18001";
65 mpd = {
66 host = "malige.home.immae.eu";
67 port = 6600;
68 };
69 };
70 apache = {
71 vhostConf = ''
72 <LocationMatch "^/mpd">
73 Use LDAPConnect
74 Require ldap-group cn=users,cn=mpd,ou=services,dc=immae,dc=eu
75 Require local
76 </LocationMatch>
77
78 RedirectMatch permanent "^/mpd$" "/mpd/"
79 <Location "/mpd/">
80 ProxyPass http://${config.webPort}/
81 ProxyPassReverse http://${config.webPort}/
82 ProxyPreserveHost on
83 </Location>
84 <Location "/mpd/ws">
85 ProxyPass ws://${config.webPort}/ws
86 </Location>
87 '';
88 };
89 };
90 in
91 {
92 inherit adminer;
93 inherit ympd;
94 }