1 { lib, writeText, fetchedGitPrivate, stdenv, composerEnv, fetchurl, fetchgit, python, nodejs, libsass, yarn2nix }:
3 aten = { config }: rec {
4 environment = config.environment;
5 varDir = "/var/lib/aten_${environment}";
7 socket = "/var/run/phpfpm/aten-${environment}.sock";
11 group = ${apache.group}
12 listen.owner = ${apache.user}
13 listen.group = ${apache.group}
14 php_admin_value[upload_max_filesize] = 20M
15 php_admin_value[post_max_size] = 20M
16 ;php_admin_flag[log_errors] = on
17 php_admin_value[open_basedir] = "${webappDir}:${varDir}:/tmp"
18 php_admin_value[session.save_path] = "${varDir}/phpSessions"
19 ${if environment == "dev" then ''
22 pm.process_idle_timeout = 60
23 env[SYMFONY_DEBUG_MODE] = "yes"
28 pm.min_spare_servers = 1
29 pm.max_spare_servers = 3
35 modules = [ "proxy_fcgi" ];
38 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
41 SetEnv APP_ENV "${environment}"
42 SetEnv APP_SECRET "${config.secret}"
43 SetEnv DATABASE_URL "${config.psql_url}"
45 ${if environment == "dev" then ''
48 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
49 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
54 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
55 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
62 Require ldap-group cn=aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
63 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
67 <Directory ${webRoot}>
68 Options Indexes FollowSymLinks MultiViews Includes
71 DirectoryIndex index.php
72 FallbackResource /index.php
77 deps = [ "wrappers" ];
79 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}
80 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
81 if [ ! -f "${varDir}/currentWebappDir" -o \
82 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
83 pushd ${webappDir} > /dev/null
84 $wrapperDir/sudo -u wwwrun APP_ENV=${environment} ./bin/console --env=${environment} cache:clear --no-warmup
86 echo -n "${webappDir}" > ${varDir}/currentWebappDir
91 info = fetchedGitPrivate ./aten.json;
93 yarn2nix.mkYarnModules {
94 name = "aten-yarn-modules";
95 packageJSON = "${info.src}/package.json";
96 yarnLock = "${info.src}/yarn.lock";
99 buildInputs = [ libsass python ];
101 nodeHeaders = fetchurl {
102 url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz";
103 sha256 = "12zzsf8my43b8qnlacp871ih5vqafl2vlpqp51xp6h3gckn2frwy";
107 node scripts/build.js --tarball=${nodeHeaders}
112 webappDir = composerEnv.buildPackage (
113 import ./php-packages.nix { inherit composerEnv fetchurl fetchgit; } //
114 fetchedGitPrivate ./aten.json //
116 noDev = (environment == "prod");
118 export SYMFONY_ENV="${environment}"
119 export APP_ENV="${environment}"
120 export DATABASE_URL="${config.psql_url}"
121 export APP_SECRET="${config.secret}"
125 ln -sf ${yarnModules}/node_modules .
126 yarn run --offline encore production
127 rm -rf var/{log,cache}
128 ln -sf ../../../../../../../${varDir}/{log,cache} var/
130 buildInputs = [ yarn2nix.yarn ];
132 webRoot = "${webappDir}/public";