1 { pkgs, lib, writeText, fetchedGitPrivate, stdenv, composerEnv, fetchurl, fetchgit, 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: ${config.mysql.host}
11 database_port: ${config.mysql.port}
12 database_name: ${config.mysql.name}
13 database_user: ${config.mysql.user}
14 database_password: ${config.mysql.password}
15 database_server_version: ${pkgs.mariadb.mysqlVersion}
16 mailer_transport: smtp
17 mailer_host: 127.0.0.1
20 secret: ${config.secret}
21 pdflatex: "${texlive.combine { inherit (texlive) attachfile preprint scheme-small; }}/bin/pdflatex"
23 binary_path: ${imagemagick}/bin
26 socket = "/var/run/phpfpm/piedsjaloux-${environment}.sock";
30 group = ${apache.group}
31 listen.owner = ${apache.user}
32 listen.group = ${apache.group}
33 php_admin_value[upload_max_filesize] = 20M
34 php_admin_value[post_max_size] = 20M
35 ;php_admin_flag[log_errors] = on
36 php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp"
37 php_admin_value[session.save_path] = "${varDir}/phpSessions"
38 env[PATH] = ${lib.makeBinPath [ pkgs.apg pkgs.unzip ]}
39 ${if environment == "dev" then ''
42 pm.process_idle_timeout = 60
43 env[SYMFONY_DEBUG_MODE] = "yes"
48 pm.min_spare_servers = 1
49 pm.max_spare_servers = 3
55 modules = [ "proxy_fcgi" ];
58 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
61 ${if environment == "dev" then ''
64 Require ldap-group cn=piedsjaloux.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
65 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>"
68 <Directory ${webRoot}>
69 Options Indexes FollowSymLinks MultiViews Includes
73 DirectoryIndex app_dev.php
75 <IfModule mod_negotiation.c>
79 <IfModule mod_rewrite.c>
82 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
83 RewriteRule ^(.*) - [E=BASE:%1]
86 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
87 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
88 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
89 ErrorDocument 503 /maintenance.php
91 # Sets the HTTP_AUTHORIZATION header removed by Apache
92 RewriteCond %{HTTP:Authorization} .
93 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
95 RewriteCond %{ENV:REDIRECT_STATUS} ^$
96 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
98 # If the requested filename exists, simply serve it.
99 # We only want to let Apache serve files and not directories.
100 RewriteCond %{REQUEST_FILENAME} -f
103 # Rewrite all other queries to the front controller.
104 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
109 Use Stats piedsjaloux.fr
111 <Directory ${webRoot}>
112 Options Indexes FollowSymLinks MultiViews Includes
120 deps = [ "wrappers" ];
122 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
124 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
125 if [ ! -f "${varDir}/currentWebappDir" -o \
126 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
127 pushd ${webappDir} > /dev/null
128 $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
130 echo -n "${webappDir}" > ${varDir}/currentWebappDir
134 webappDir = composerEnv.buildPackage (
135 import ./php-packages.nix { inherit composerEnv fetchurl fetchgit; } //
136 fetchedGitPrivate ./piedsjaloux.json //
138 noDev = (environment == "prod");
140 export SYMFONY_ENV="${environment}"
142 # /!\ miniatures and data need to be in the same physical dir due to a
143 # bug in leapt.im (searches for data/../miniatures)
146 rm app/config/parameters.yml
147 ln -sf ${configRoot} app/config/parameters.yml
148 rm -rf var/{logs,cache,data,miniatures,tmp}
149 ln -sf ../../../../../../../${varDir}/{logs,cache,data,miniatures,tmp} var/
152 webRoot = "${webappDir}/web";