1 { lib, writeText, fetchedGitPrivate, stdenv, runCommand, composerEnv, fetchurl, fetchgit, jq, python, nodejs, libsass, yarn2nixPackage }:
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" ];
36 webappName = "aten_${environment}";
37 root = "/run/current-system/webapps/${webappName}";
40 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
43 SetEnv APP_ENV "${environment}"
44 SetEnv APP_SECRET "${config.secret}"
45 SetEnv DATABASE_URL "${config.psql_url}"
47 ${if environment == "dev" then ''
50 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
51 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
56 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
57 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
64 Require ldap-group cn=aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
65 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
70 Options Indexes FollowSymLinks MultiViews Includes
73 DirectoryIndex index.php
74 FallbackResource /index.php
79 deps = [ "wrappers" ];
81 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}
82 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
83 if [ ! -f "${varDir}/currentWebappDir" -o \
84 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
85 pushd ${webappDir} > /dev/null
86 $wrapperDir/sudo -u wwwrun APP_ENV=${environment} ./bin/console --env=${environment} cache:clear --no-warmup
88 echo -n "${webappDir}" > ${varDir}/currentWebappDir
93 info = fetchedGitPrivate ./aten.json;
94 packagejson = runCommand "package.json" { buildInputs = [ jq ]; } ''
95 cat ${info.src}/package.json | jq -r '.version = "v1.0.0"|.name="aten"' > $out
98 yarn2nixPackage.mkYarnModules rec {
102 packageJSON = packagejson;
103 yarnLock = "${info.src}/yarn.lock";
106 buildInputs = [ libsass python ];
108 nodeHeaders = fetchurl {
109 url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz";
110 sha256 = "16f20ya3ys6w5w6y6l4536f7jrgk4gz46bf71w1r1xxb26a54m32";
114 node scripts/build.js --tarball=${nodeHeaders}
119 webappDir = composerEnv.buildPackage (
120 import ./php-packages.nix { inherit composerEnv fetchurl fetchgit; } //
121 fetchedGitPrivate ./aten.json //
123 noDev = (environment == "prod");
125 export SYMFONY_ENV="${environment}"
126 export APP_ENV="${environment}"
127 export DATABASE_URL="${config.psql_url}"
128 export APP_SECRET="${config.secret}"
131 ln -sf ${yarnModules}/node_modules .
132 yarn run --offline encore production
133 rm -rf var/{log,cache}
134 ln -sf ${varDir}/{log,cache} var/
136 buildInputs = [ yarnModules yarn2nixPackage.yarn ];
138 webRoot = "${webappDir}/public";