1 { pkgs, lib, writeText, fetchedGitPrivate, stdenv, composerEnv, fetchurl, fetchgit }:
3 connexionswing = { config }: rec {
4 environment = config.environment;
5 varDir = "/var/lib/connexionswing_${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 database_server_version: ${pkgs.mariadb.mysqlVersion}
16 mailer_transport: smtp
17 mailer_host: mail.immae.eu
20 subscription_email: ${config.email}
22 secret: ${config.secret}
25 socket = "/var/run/phpfpm/connexionswing-${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 <Directory ${varDir}/medias>
60 Options FollowSymLinks
65 <Directory ${varDir}/uploads>
66 Options FollowSymLinks
71 ${if environment == "dev" then ''
74 Require ldap-group cn=connexionswing.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
75 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://connexionswing.com\"></html>"
78 <Directory ${webRoot}>
79 Options Indexes FollowSymLinks MultiViews Includes
83 DirectoryIndex app_dev.php
85 <IfModule mod_negotiation.c>
89 <IfModule mod_rewrite.c>
92 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
93 RewriteRule ^(.*) - [E=BASE:%1]
96 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
97 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
98 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
99 ErrorDocument 503 /maintenance.php
101 # Sets the HTTP_AUTHORIZATION header removed by Apache
102 RewriteCond %{HTTP:Authorization} .
103 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
105 RewriteCond %{ENV:REDIRECT_STATUS} ^$
106 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
108 # If the requested filename exists, simply serve it.
109 # We only want to let Apache serve files and not directories.
110 RewriteCond %{REQUEST_FILENAME} -f
113 # Rewrite all other queries to the front controller.
114 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
119 Use Stats connexionswing.com
121 <Directory ${webRoot}>
122 Options Indexes FollowSymLinks MultiViews Includes
130 deps = [ "wrappers" ];
132 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
136 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
137 if [ ! -f "${varDir}/currentWebappDir" -o \
138 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
139 pushd ${webappDir} > /dev/null
140 $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
142 echo -n "${webappDir}" > ${varDir}/currentWebappDir
146 webappDir = composerEnv.buildPackage (
147 import ./php-packages.nix { inherit composerEnv fetchurl fetchgit; } //
148 fetchedGitPrivate ./connexionswing.json //
150 noDev = (environment == "prod");
152 export SYMFONY_ENV="${environment}"
156 ${if environment == "prod" then "php ./bin/console assetic:dump --env=prod --no-debug" else ""}
157 rm app/config/parameters.yml
158 ln -sf ${configRoot} app/config/parameters.yml
159 rm -rf var/{logs,cache}
160 ln -sf ../../../../../../${varDir}/var/{logs,cache} var/
161 ln -sf ../../../../../${varDir}/{medias,uploads} web/images/
164 webRoot = "${webappDir}/web";