1 { pkgs, lib, writeText, fetchedGitPrivate, stdenv, composerEnv, fetchurl, fetchgit, ruby, sass, imagemagick }:
3 ludivinecassal = { config }: rec {
4 environment = config.environment;
5 varDir = "/var/lib/ludivinecassal_${environment}";
6 keys."${environment}-ludivinecassal" = {
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: smtp
21 mailer_host: 127.0.0.1
24 secret: ${config.secret}
25 ldap_host: ldap.immae.eu
30 ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu'
31 ldap_base_dn: 'dc=immae,dc=eu'
32 ldap_search_dn: '${config.ldap.dn}'
33 ldap_search_password: '${config.ldap.password}'
34 ldap_search_filter: '${config.ldap.search}'
36 binary_path: ${imagemagick}/bin
38 sass: ${sass}/bin/sass
39 ruby: ${ruby}/bin/ruby
43 socket = "/var/run/phpfpm/ludivinecassal-${environment}.sock";
47 group = ${apache.group}
48 listen.owner = ${apache.user}
49 listen.group = ${apache.group}
50 php_admin_value[upload_max_filesize] = 20M
51 php_admin_value[post_max_size] = 20M
52 ;php_admin_flag[log_errors] = on
53 php_admin_value[open_basedir] = "/run/keys/webapps/${environment}-ludivinecassal:${webappDir}:${varDir}:/tmp"
54 php_admin_value[session.save_path] = "${varDir}/phpSessions"
55 ${if environment == "dev" then ''
58 pm.process_idle_timeout = 60
59 env[SYMFONY_DEBUG_MODE] = "yes"
64 pm.min_spare_servers = 1
65 pm.max_spare_servers = 3
71 modules = [ "proxy_fcgi" ];
72 webappName = "ludivine_${environment}";
73 root = "/run/current-system/webapps/${webappName}";
76 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
79 ${if environment == "dev" then ''
82 Require ldap-group cn=ludivine.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
83 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://ludivinecassal.com\"></html>"
87 Options Indexes FollowSymLinks MultiViews Includes
91 DirectoryIndex app_dev.php
93 <IfModule mod_negotiation.c>
97 <IfModule mod_rewrite.c>
100 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
101 RewriteRule ^(.*) - [E=BASE:%1]
104 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
105 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
106 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
107 ErrorDocument 503 /maintenance.php
109 # Sets the HTTP_AUTHORIZATION header removed by Apache
110 RewriteCond %{HTTP:Authorization} .
111 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
113 RewriteCond %{ENV:REDIRECT_STATUS} ^$
114 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
116 # If the requested filename exists, simply serve it.
117 # We only want to let Apache serve files and not directories.
118 RewriteCond %{REQUEST_FILENAME} -f
121 # Rewrite all other queries to the front controller.
122 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
127 Use Stats ludivinecassal.com
130 Options Indexes FollowSymLinks MultiViews Includes
138 deps = [ "wrappers" ];
140 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}
141 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}/tmp
142 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
143 if [ ! -f "${varDir}/currentWebappDir" -o \
144 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
145 pushd ${webappDir} > /dev/null
146 $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
148 echo -n "${webappDir}" > ${varDir}/currentWebappDir
152 webappDir = composerEnv.buildPackage (
153 import ./php-packages.nix { inherit composerEnv fetchurl fetchgit; } //
154 fetchedGitPrivate ./ludivinecassal.json //
156 noDev = (environment == "prod");
158 export SYMFONY_ENV="${environment}"
159 cp app/config/parameters.yml.dist app/config/parameters.yml
160 cat >> app/config/parameters.yml <<EOF
162 binary_path: ${imagemagick}/bin
164 sass: ${sass}/bin/sass
165 ruby: ${ruby}/bin/ruby
167 sed -i -e "/Incenteev..ParameterHandler..ScriptHandler::buildParameters/d" composer.json
169 # /!\ miniatures and data need to be in the same physical dir due to a
170 # bug in leapt.im (searches for data/../miniatures)
172 rm -rf var/{logs,cache,data,miniatures,tmp}
173 ln -sf ${varDir}/{logs,cache,data,miniatures,tmp} var/
174 ln -sf /run/keys/webapps/${environment}-ludivinecassal app/config/parameters.yml
176 buildInputs = [ sass ];
178 webRoot = "${webappDir}/web";