]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - virtual/packages/chloe.nix
Disable ympd and add some fixmes
[perso/Immae/Config/Nix.git] / virtual / packages / chloe.nix
CommitLineData
7d8b50d3
IB
1{ stdenv, lib, checkEnv, fetchzip, fetchurl, fetchedGitPrivate, sassc }:
2let
3 chloe = { environment ? "dev" }: rec {
4 varPrefix = "CHLOE";
5 envName= lib.strings.toUpper environment;
6 phpFpm = rec {
7 socket = "/var/run/phpfpm/chloe-${environment}.sock";
8 pool =
9 assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD";
10 assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER";
11 assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_DB";
12 assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_DN";
13 assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_PASSWORD";
14 assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH";
15 ''
16 listen = ${socket}
17 user = ${apache.user}
18 group = ${apache.group}
19 listen.owner = ${apache.user}
20 listen.group = ${apache.group}
21 php_admin_value[upload_max_filesize] = 20M
22 php_admin_value[post_max_size] = 20M
23 ;php_admin_flag[log_errors] = on
24 php_admin_value[open_basedir] = "${./spip_mes_options.php}:${configDir}:${webRoot}:${varDir}:/tmp"
25 env[SPIP_CONFIG_DIR] = "${configDir}"
26 env[SPIP_LDAP_BASE] = "dc=immae,dc=eu"
27 env[SPIP_LDAP_HOST] = "ldaps://ldap.immae.eu"
28 env[SPIP_LDAP_SEARCH_DN] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_DN"}"
29 env[SPIP_LDAP_SEARCH_PW] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_PASSWORD"}"
30 env[SPIP_LDAP_SEARCH] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH"}"
31 env[SPIP_MYSQL_HOST] = "db-1.immae.eu"
32 env[SPIP_MYSQL_DB] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_DB"}"
33 env[SPIP_MYSQL_USER] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER"}"
34 env[SPIP_MYSQL_PASSWORD] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD"}"
35 ${if environment == "dev" then ''
36 pm = ondemand
37 pm.max_children = 5
38 pm.process_idle_timeout = 60
39 '' else ''
40 pm = dynamic
41 pm.max_children = 20
42 pm.start_servers = 2
43 pm.min_spare_servers = 1
44 pm.max_spare_servers = 3
45 ''}'';
46 };
47 apache = {
48 user = "wwwrun";
49 group = "wwwrun";
50 modules = [ "proxy_fcgi" ];
51 vhostConf = ''
52 RewriteEngine On
53 ${if environment == "prod" then ''
54 RewriteRule ^/news.rss /spip.php?page=backend&id_rubrique=1
55 '' else ""}
56
57 <FilesMatch "\.php$">
58 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
59 </FilesMatch>
60
61 <Directory ${webRoot}>
62 DirectoryIndex index.php index.htm index.html
63 Options -Indexes +FollowSymLinks +MultiViews +Includes
64 Include ${webRoot}/htaccess.txt
65
66 AllowOverride AuthConfig FileInfo Limit
67 Require all granted
68 </Directory>
69
70 <DirectoryMatch "${varDir}/tmp">
71 Require all denied
72 </DirectoryMatch>
73
74 <DirectoryMatch "${webRoot}/squelettes">
75 Require all denied
76 </DirectoryMatch>
77
78 <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$">
79 Require all denied
80 </FilesMatch>
81
82 ${if environment == "dev" then ''
83 <Location />
84 Use LDAPConnect
85 Require ldap-group cn=chloe.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
86 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://osteopathe-cc.fr\"></html>"
87 </Location>
6bd6d033
IB
88 '' else ''
89 Use Stats osteopathe-cc.fr
90 ''}
7d8b50d3
IB
91 '';
92 };
93 activationScript = {
94 deps = [ "wrappers" ];
95 text = ''
96 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} ${varDir}/tmp ${varDir}/local
97 '';
98 };
99 configDir = ./chloe_config;
100 varDir = "/var/lib/chloe_${environment}";
101 siteDir = stdenv.mkDerivation (fetchedGitPrivate ./chloe.json // rec {
102 buildPhase = ''
103 make
104 '';
105 installPhase = ''
106 cp -a . $out
107 '';
108 buildInputs = [ sassc ];
109 });
110 webRoot = stdenv.mkDerivation rec {
111 name = "spip-${version}";
112 version = "3.2";
113 src = fetchzip {
114 url = "http://files.spip.org/spip/stable/${name}.zip";
115 sha256 = "0cacpxs9nv61i3hzd3nbmplq4mp22s886llhacp3n4923jd6snx5";
116 };
117 paches = [ ./spip_ldap_patch.patch ];
118 buildPhase = ''
119 rm -rf IMG local tmp config/remove.txt
120 ln -sf ${./spip_mes_options.php} config/mes_options.php
121 echo "Require all denied" > "config/.htaccess"
122 ln -sf ../../../../../${varDir}/{IMG,local,tmp} .
123 '';
124 installPhase = ''
125 cp -a . $out
126 cp -a ${siteDir}/* $out
127 '';
128 };
129 };
130in
131 chloe