1 { lib, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, texlive, imagemagick }:
3 piedsjaloux = { config }: rec {
4 environment = config.environment;
5 varDir = "/var/lib/piedsjaloux_${environment}";
7 writeText "parameters.yml" ''
8 # This file is auto-generated during the composer install
10 database_host: db-1.immae.eu
12 database_name: ${config.mysql.name}
13 database_user: ${config.mysql.user}
14 database_password: ${config.mysql.password}
15 mailer_transport: smtp
16 mailer_host: mail.immae.eu
19 secret: ${config.secret}
20 pdflatex: "${texlive.combine { inherit (texlive) attachfile preprint scheme-small; }}/bin/pdflatex"
22 binary_path: ${imagemagick}/bin
25 socket = "/var/run/phpfpm/piedsjaloux-${environment}.sock";
29 group = ${apache.group}
30 listen.owner = ${apache.user}
31 listen.group = ${apache.group}
32 php_admin_value[upload_max_filesize] = 20M
33 php_admin_value[post_max_size] = 20M
34 ;php_admin_flag[log_errors] = on
35 php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp"
36 php_admin_value[session.save_path] = "${varDir}/phpSessions"
37 ${if environment == "dev" then ''
40 pm.process_idle_timeout = 60
41 env[SYMFONY_DEBUG_MODE] = "yes"
46 pm.min_spare_servers = 1
47 pm.max_spare_servers = 3
53 modules = [ "proxy_fcgi" ];
56 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
59 ${if environment == "dev" then ''
62 Require ldap-group cn=piedsjaloux.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
63 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>"
66 <Directory ${webRoot}>
67 Options Indexes FollowSymLinks MultiViews Includes
71 DirectoryIndex app_dev.php
73 <IfModule mod_negotiation.c>
77 <IfModule mod_rewrite.c>
80 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
81 RewriteRule ^(.*) - [E=BASE:%1]
84 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
85 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
86 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
87 ErrorDocument 503 /maintenance.php
89 # Sets the HTTP_AUTHORIZATION header removed by Apache
90 RewriteCond %{HTTP:Authorization} .
91 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
93 RewriteCond %{ENV:REDIRECT_STATUS} ^$
94 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
96 # If the requested filename exists, simply serve it.
97 # We only want to let Apache serve files and not directories.
98 RewriteCond %{REQUEST_FILENAME} -f
101 # Rewrite all other queries to the front controller.
102 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
107 Use Stats piedsjaloux.fr
109 <Directory ${webRoot}>
110 Options Indexes FollowSymLinks MultiViews Includes
118 deps = [ "wrappers" ];
120 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
122 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
123 if [ ! -f "${varDir}/currentWebappDir" -o \
124 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
125 pushd ${webappDir} > /dev/null
126 $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
128 echo -n "${webappDir}" > ${varDir}/currentWebappDir
132 webappDir = stdenv.mkDerivation (fetchedGitPrivate ./piedsjaloux.json // rec {
133 # /!\ miniatures and data need to be in the same dir due to a
134 # bug in leapt.im (searches for data/../miniatures)
136 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
137 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
139 ln -sf ${configRoot} app/config/parameters.yml
140 sed -i -e "/Incenteev..ParameterHandler..ScriptHandler::buildParameters/d" composer.json
141 ${if environment == "dev" then ''
144 SYMFONY_ENV=prod composer install --no-dev
147 ln -sf ../../../../../${varDir} var
153 php git cacert phpPackages.composer
156 webRoot = "${webappDir}/web";