1 { pkgs, lib, writeText, fetchedGitPrivate, stdenv, composerEnv, phpPackages, fetchurl, fetchgit }:
3 connexionswing = { config }: rec {
4 environment = config.environment;
5 varDir = "/var/lib/connexionswing_${environment}";
6 keys."${environment}-connexionswing" = {
7 destDir = "/run/keys/webapps";
12 # This file is auto-generated during the composer install
14 database_host: ${config.mysql.host}
15 database_port: ${config.mysql.port}
16 database_name: ${config.mysql.name}
17 database_user: ${config.mysql.user}
18 database_password: ${config.mysql.password}
19 database_server_version: ${pkgs.mariadb.mysqlVersion}
20 mailer_transport: sendmail
24 subscription_email: ${config.email}
26 secret: ${config.secret}
27 ${if environment == "prod" then ''
29 swiftmailer.mailer.default.transport:
30 class: Swift_SendmailTransport
31 arguments: ['/run/wrappers/bin/sendmail -bs']
36 socket = "/var/run/phpfpm/connexionswing-${environment}.sock";
38 extension=${phpPackages.imagick}/lib/php/extensions/imagick.so
43 group = ${apache.group}
44 listen.owner = ${apache.user}
45 listen.group = ${apache.group}
46 php_admin_value[upload_max_filesize] = 20M
47 php_admin_value[post_max_size] = 20M
48 ;php_admin_flag[log_errors] = on
49 php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:/run/keys/webapps/${environment}-connexionswing:${webappDir}:${varDir}:/tmp"
50 php_admin_value[session.save_path] = "${varDir}/phpSessions"
51 ${if environment == "dev" then ''
54 pm.process_idle_timeout = 60
55 env[SYMFONY_DEBUG_MODE] = "yes"
60 pm.min_spare_servers = 1
61 pm.max_spare_servers = 3
67 modules = [ "proxy_fcgi" ];
68 webappName = "connexionswing_${environment}";
69 root = "/run/current-system/webapps/${webappName}";
72 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
75 <Directory ${varDir}/medias>
76 Options FollowSymLinks
81 <Directory ${varDir}/uploads>
82 Options FollowSymLinks
87 ${if environment == "dev" then ''
90 Require ldap-group cn=connexionswing.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
91 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://connexionswing.com\"></html>"
95 Options Indexes FollowSymLinks MultiViews Includes
99 DirectoryIndex app_dev.php
101 <IfModule mod_negotiation.c>
105 <IfModule mod_rewrite.c>
108 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
109 RewriteRule ^(.*) - [E=BASE:%1]
112 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
113 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
114 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
115 ErrorDocument 503 /maintenance.php
117 # Sets the HTTP_AUTHORIZATION header removed by Apache
118 RewriteCond %{HTTP:Authorization} .
119 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
121 RewriteCond %{ENV:REDIRECT_STATUS} ^$
122 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
124 # If the requested filename exists, simply serve it.
125 # We only want to let Apache serve files and not directories.
126 RewriteCond %{REQUEST_FILENAME} -f
129 # Rewrite all other queries to the front controller.
130 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
135 Use Stats connexionswing.com
138 Options Indexes FollowSymLinks MultiViews Includes
146 deps = [ "wrappers" ];
148 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
152 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
153 if [ ! -f "${varDir}/currentWebappDir" -o \
154 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
155 pushd ${webappDir} > /dev/null
156 $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
158 echo -n "${webappDir}" > ${varDir}/currentWebappDir
162 webappDir = composerEnv.buildPackage (
163 import ./php-packages.nix { inherit composerEnv fetchurl fetchgit; } //
164 fetchedGitPrivate ./connexionswing.json //
166 noDev = (environment == "prod");
168 export SYMFONY_ENV="${environment}"
172 ${if environment == "prod" then "php ./bin/console assetic:dump --env=prod --no-debug" else ""}
173 rm app/config/parameters.yml
174 ln -sf /run/keys/webapps/${environment}-connexionswing app/config/parameters.yml
175 rm -rf var/{logs,cache}
176 ln -sf ${varDir}/var/{logs,cache} var/
177 ln -sf ${varDir}/{medias,uploads} web/images/
180 webRoot = "${webappDir}/web";