1 { lib, writeText, fetchedGitPrivate, fetchurl, stdenv, composerEnv }:
3 tellesflorian = { config }: rec {
4 environment = config.environment;
5 varDir = "/var/lib/tellesflorian_${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 mailer_transport: smtp
16 mailer_host: 127.0.0.1
19 secret: ${config.secret}
22 socket = "/var/run/phpfpm/floriantelles-${environment}.sock";
26 group = ${apache.group}
27 listen.owner = ${apache.user}
28 listen.group = ${apache.group}
29 php_admin_value[upload_max_filesize] = 20M
30 php_admin_value[post_max_size] = 20M
31 ;php_admin_flag[log_errors] = on
32 php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp"
33 php_admin_value[session.save_path] = "${varDir}/phpSessions"
34 ${if environment == "dev" then ''
37 pm.process_idle_timeout = 60
38 env[SYMFONY_DEBUG_MODE] = "yes"
43 pm.min_spare_servers = 1
44 pm.max_spare_servers = 3
47 passwords = writeText "tellesflorian_passwords" ''
48 invite:${config.invite_passwords}
53 modules = [ "proxy_fcgi" ];
54 webappName = "florian_${environment}";
55 root = "/run/current-system/webapps/${webappName}";
58 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
61 ${if environment == "dev" then ''
63 AuthBasicProvider file ldap
65 Require ldap-group cn=app.tellesflorian.com,cn=httpd,ou=services,dc=immae,dc=eu
67 AuthUserFile "${passwords}"
70 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://tellesflorian.com\"></html>"
74 Options Indexes FollowSymLinks MultiViews Includes
78 DirectoryIndex app_dev.php
80 <IfModule mod_negotiation.c>
84 <IfModule mod_rewrite.c>
87 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
88 RewriteRule ^(.*) - [E=BASE:%1]
91 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
92 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
93 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
94 ErrorDocument 503 /maintenance.php
96 # Sets the HTTP_AUTHORIZATION header removed by Apache
97 RewriteCond %{HTTP:Authorization} .
98 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
100 RewriteCond %{ENV:REDIRECT_STATUS} ^$
101 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
103 # If the requested filename exists, simply serve it.
104 # We only want to let Apache serve files and not directories.
105 RewriteCond %{REQUEST_FILENAME} -f
108 # Rewrite all other queries to the front controller.
109 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
115 Options Indexes FollowSymLinks MultiViews Includes
123 deps = [ "wrappers" ];
125 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
127 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
128 if [ ! -f "${varDir}/currentWebappDir" -o \
129 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
130 pushd ${webappDir} > /dev/null
131 $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
133 echo -n "${webappDir}" > ${varDir}/currentWebappDir
137 webappDir = composerEnv.buildPackage (
138 import ./php-packages.nix { inherit composerEnv fetchurl; } //
139 fetchedGitPrivate ./tellesflorian.json //
141 noDev = (environment == "prod");
143 export SYMFONY_ENV="${environment}"
147 rm app/config/parameters.yml
148 ln -sf ${configRoot} app/config/parameters.yml
149 rm -rf var/{logs,cache}
150 ln -sf ${varDir}/var/{logs,cache,sessions} var/
153 webRoot = "${webappDir}/web";