-{ lib, writeText, fetchedGitPrivate, fetchurl, stdenv, composerEnv }:
-let
- tellesflorian = { config }: rec {
- environment = config.environment;
- varDir = "/var/lib/tellesflorian_${environment}";
- keys = [
- {
- dest = "webapps/${environment}-tellesflorian-passwords";
- user = apache.user;
- group = apache.group;
- permissions = "0400";
- text = ''
- invite:${config.invite_passwords}
- '';
- }
- {
- dest = "webapps/${environment}-tellesflorian";
- user = apache.user;
- group = apache.group;
- permissions = "0400";
- text = ''
- # This file is auto-generated during the composer install
- parameters:
- database_host: ${config.mysql.host}
- database_port: ${config.mysql.port}
- database_name: ${config.mysql.name}
- database_user: ${config.mysql.user}
- database_password: ${config.mysql.password}
- mailer_transport: smtp
- mailer_host: 127.0.0.1
- mailer_user: null
- mailer_password: null
- secret: ${config.secret}
- '';
- }
- ];
- phpFpm = rec {
- preStart = ''
- if [ ! -f "${varDir}/currentWebappDir" -o \
- ! -f "${varDir}/currentKey" -o \
- "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \
- || ! sha512sum -c --status ${varDir}/currentKey; then
- pushd ${webappDir} > /dev/null
- /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
- popd > /dev/null
- echo -n "${webappDir}" > ${varDir}/currentWebappDir
- sha512sum /var/secrets/webapps/${environment}-tellesflorian > ${varDir}/currentKey
- fi
- '';
- serviceDeps = [ "mysql.service" ];
- socket = "/var/run/phpfpm/floriantelles-${environment}.sock";
- pool = ''
- listen = ${socket}
- user = ${apache.user}
- group = ${apache.group}
- listen.owner = ${apache.user}
- listen.group = ${apache.group}
- php_admin_value[upload_max_filesize] = 20M
- php_admin_value[post_max_size] = 20M
- ;php_admin_flag[log_errors] = on
- php_admin_value[open_basedir] = "/var/secrets/webapps/${environment}-tellesflorian:${webappDir}:${varDir}:/tmp"
- php_admin_value[session.save_path] = "${varDir}/phpSessions"
- ${if environment == "dev" then ''
- pm = ondemand
- pm.max_children = 5
- pm.process_idle_timeout = 60
- env[SYMFONY_DEBUG_MODE] = "yes"
- '' else ''
- pm = dynamic
- pm.max_children = 20
- pm.start_servers = 2
- pm.min_spare_servers = 1
- pm.max_spare_servers = 3
- ''}'';
- };
- apache = rec {
- user = "wwwrun";
- group = "wwwrun";
- modules = [ "proxy_fcgi" ];
- webappName = "florian_${environment}";
- root = "/run/current-system/webapps/${webappName}";
- vhostConf = ''
- <FilesMatch "\.php$">
- SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
- </FilesMatch>
+{ tellesflorian, config }:
+rec {
+ app = tellesflorian.override { inherit (config) environment; };
+ keys = [
+ {
+ dest = "webapps/${app.environment}-tellesflorian-passwords";
+ user = apache.user;
+ group = apache.group;
+ permissions = "0400";
+ text = ''
+ invite:${config.invite_passwords}
+ '';
+ }
+ {
+ dest = "webapps/${app.environment}-tellesflorian";
+ user = apache.user;
+ group = apache.group;
+ permissions = "0400";
+ text = ''
+ # This file is auto-generated during the composer install
+ parameters:
+ database_host: ${config.mysql.host}
+ database_port: ${config.mysql.port}
+ database_name: ${config.mysql.name}
+ database_user: ${config.mysql.user}
+ database_password: ${config.mysql.password}
+ mailer_transport: smtp
+ mailer_host: 127.0.0.1
+ mailer_user: null
+ mailer_password: null
+ secret: ${config.secret}
+ '';
+ }
+ ];
+ phpFpm = rec {
+ preStart = ''
+ if [ ! -f "${app.varDir}/currentWebappDir" -o \
+ ! -f "${app.varDir}/currentKey" -o \
+ "${app}" != "$(cat ${app.varDir}/currentWebappDir 2>/dev/null)" ] \
+ || ! sha512sum -c --status ${app.varDir}/currentKey; then
+ pushd ${app} > /dev/null
+ /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=${app.environment} cache:clear --no-warmup
+ popd > /dev/null
+ echo -n "${app}" > ${app.varDir}/currentWebappDir
+ sha512sum /var/secrets/webapps/${app.environment}-tellesflorian > ${app.varDir}/currentKey
+ fi
+ '';
+ serviceDeps = [ "mysql.service" ];
+ socket = "/var/run/phpfpm/floriantelles-${app.environment}.sock";
+ pool = ''
+ listen = ${socket}
+ user = ${apache.user}
+ group = ${apache.group}
+ listen.owner = ${apache.user}
+ listen.group = ${apache.group}
+ php_admin_value[upload_max_filesize] = 20M
+ php_admin_value[post_max_size] = 20M
+ ;php_admin_flag[log_errors] = on
+ php_admin_value[open_basedir] = "/var/secrets/webapps/${app.environment}-tellesflorian:${app}:${app.varDir}:/tmp"
+ php_admin_value[session.save_path] = "${app.varDir}/phpSessions"
+ ${if app.environment == "dev" then ''
+ pm = ondemand
+ pm.max_children = 5
+ pm.process_idle_timeout = 60
+ env[SYMFONY_DEBUG_MODE] = "yes"
+ '' else ''
+ pm = dynamic
+ pm.max_children = 20
+ pm.start_servers = 2
+ pm.min_spare_servers = 1
+ pm.max_spare_servers = 3
+ ''}'';
+ };
+ apache = rec {
+ user = "wwwrun";
+ group = "wwwrun";
+ modules = [ "proxy_fcgi" ];
+ webappName = "florian_${app.environment}";
+ root = "/run/current-system/webapps/${webappName}";
+ vhostConf = ''
+ <FilesMatch "\.php$">
+ SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+ </FilesMatch>