1 { pkgs, lib, writeText, fetchedGitPrivate, stdenv, composerEnv, phpPackages, fetchurl, fetchgit }:
3 connexionswing = { config }: rec {
4 environment = config.environment;
5 varDir = "/var/lib/connexionswing_${environment}";
7 dest = "webapps/${environment}-connexionswing";
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']
37 if [ ! -f "${varDir}/currentWebappDir" -o \
38 ! -f "${varDir}/currentKey" -o \
39 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \
40 || ! sha512sum -c --status ${varDir}/currentKey; then
41 pushd ${webappDir} > /dev/null
42 /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
44 echo -n "${webappDir}" > ${varDir}/currentWebappDir
45 sha512sum /var/secrets/webapps/${environment}-connexionswing > ${varDir}/currentKey
48 serviceDeps = [ "mysql.service" ];
49 socket = "/var/run/phpfpm/connexionswing-${environment}.sock";
51 extension=${phpPackages.imagick}/lib/php/extensions/imagick.so
56 group = ${apache.group}
57 listen.owner = ${apache.user}
58 listen.group = ${apache.group}
59 php_admin_value[upload_max_filesize] = 20M
60 php_admin_value[post_max_size] = 20M
61 ;php_admin_flag[log_errors] = on
62 php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:/var/secrets/webapps/${environment}-connexionswing:${webappDir}:${varDir}:/tmp"
63 php_admin_value[session.save_path] = "${varDir}/phpSessions"
64 ${if environment == "dev" then ''
67 pm.process_idle_timeout = 60
68 env[SYMFONY_DEBUG_MODE] = "yes"
73 pm.min_spare_servers = 1
74 pm.max_spare_servers = 3
80 modules = [ "proxy_fcgi" ];
81 webappName = "connexionswing_${environment}";
82 root = "/run/current-system/webapps/${webappName}";
85 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
88 <Directory ${varDir}/medias>
89 Options FollowSymLinks
94 <Directory ${varDir}/uploads>
95 Options FollowSymLinks
100 ${if environment == "dev" then ''
103 Require ldap-group cn=connexionswing.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
104 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://connexionswing.com\"></html>"
108 Options Indexes FollowSymLinks MultiViews Includes
112 DirectoryIndex app_dev.php
114 <IfModule mod_negotiation.c>
118 <IfModule mod_rewrite.c>
121 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
122 RewriteRule ^(.*) - [E=BASE:%1]
125 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
126 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
127 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
128 ErrorDocument 503 /maintenance.php
130 # Sets the HTTP_AUTHORIZATION header removed by Apache
131 RewriteCond %{HTTP:Authorization} .
132 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
134 RewriteCond %{ENV:REDIRECT_STATUS} ^$
135 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
137 # If the requested filename exists, simply serve it.
138 # We only want to let Apache serve files and not directories.
139 RewriteCond %{REQUEST_FILENAME} -f
142 # Rewrite all other queries to the front controller.
143 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
148 Use Stats connexionswing.com
151 Options Indexes FollowSymLinks MultiViews Includes
159 deps = [ "wrappers" ];
161 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
165 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
168 webappDir = composerEnv.buildPackage (
169 import ./php-packages.nix { inherit composerEnv fetchurl fetchgit; } //
170 fetchedGitPrivate ./connexionswing.json //
172 noDev = (environment == "prod");
174 export SYMFONY_ENV="${environment}"
178 ${if environment == "prod" then "php ./bin/console assetic:dump --env=prod --no-debug" else ""}
179 rm app/config/parameters.yml
180 ln -sf /var/secrets/webapps/${environment}-connexionswing app/config/parameters.yml
181 rm -rf var/{logs,cache}
182 ln -sf ${varDir}/var/{logs,cache} var/
183 ln -sf ${varDir}/{medias,uploads} web/images/
186 webRoot = "${webappDir}/web";