1 { lib, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, ruby, sass, imagemagick }:
3 ludivinecassal = { config }: rec {
4 environment = config.environment;
5 varDir = "/var/lib/ludivinecassal_${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 mailer_transport: smtp
16 mailer_host: mail.immae.eu
19 secret: ${config.secret}
20 ldap_host: ldap.immae.eu
25 ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu'
26 ldap_base_dn: 'dc=immae,dc=eu'
27 ldap_search_dn: '${config.ldap.dn}'
28 ldap_search_password: '${config.ldap.password}'
29 ldap_search_filter: '${config.ldap.search}'
31 binary_path: ${imagemagick}/bin
33 sass: ${sass}/bin/sass
34 ruby: ${ruby}/bin/ruby
37 socket = "/var/run/phpfpm/ludivinecassal-${environment}.sock";
41 group = ${apache.group}
42 listen.owner = ${apache.user}
43 listen.group = ${apache.group}
44 php_admin_value[upload_max_filesize] = 20M
45 php_admin_value[post_max_size] = 20M
46 ;php_admin_flag[log_errors] = on
47 php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp"
48 php_admin_value[session.save_path] = "${varDir}/phpSessions"
49 ${if environment == "dev" then ''
52 pm.process_idle_timeout = 60
53 env[SYMFONY_DEBUG_MODE] = "yes"
58 pm.min_spare_servers = 1
59 pm.max_spare_servers = 3
65 modules = [ "proxy_fcgi" ];
68 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
71 ${if environment == "dev" then ''
74 Require ldap-group cn=ludivine.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
75 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://ludivinecassal.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 ludivinecassal.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}
133 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}/tmp
134 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
135 if [ ! -f "${varDir}/currentWebappDir" -o \
136 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
137 pushd ${webappDir} > /dev/null
138 $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
140 echo -n "${webappDir}" > ${varDir}/currentWebappDir
144 webappDir = stdenv.mkDerivation (fetchedGitPrivate ./ludivinecassal.json // rec {
145 # /!\ miniatures and data need to be in the same dir due to a
146 # bug in leapt.im (searches for data/../miniatures)
148 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
149 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
151 ln -sf ${configRoot} app/config/parameters.yml
152 sed -i -e "/Incenteev..ParameterHandler..ScriptHandler::buildParameters/d" composer.json
153 ${if environment == "dev" then ''
156 SYMFONY_ENV=prod composer install --no-dev
159 ln -sf ../../../../../${varDir} var
165 php git cacert phpPackages.composer sass
168 webRoot = "${webappDir}/web";