aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--virtual/eldiron.nix35
-rw-r--r--virtual/packages.nix3
-rw-r--r--virtual/packages/aten.json14
-rw-r--r--virtual/packages/aten.nix122
4 files changed, 173 insertions, 1 deletions
diff --git a/virtual/eldiron.nix b/virtual/eldiron.nix
index d76977c..68eddf6 100644
--- a/virtual/eldiron.nix
+++ b/virtual/eldiron.nix
@@ -107,7 +107,7 @@
107 "sandetludo.immae.eu" = null; 107 "sandetludo.immae.eu" = null;
108 "cloud.immae.eu" = null; 108 "cloud.immae.eu" = null;
109 "ludivine.immae.eu" = null; 109 "ludivine.immae.eu" = null;
110 "ludivinecassal.com" = null; 110 "dev.aten.pro" = null;
111 }; 111 };
112 }; 112 };
113 "ludivinecassal" = { 113 "ludivinecassal" = {
@@ -122,6 +122,18 @@
122 "www.ludivinecassal.com" = null; 122 "www.ludivinecassal.com" = null;
123 }; 123 };
124 }; 124 };
125 "aten" = {
126 webroot = "/var/lib/acme/acme-challenge";
127 email = "ismael@bouya.org";
128 domain = "aten.pro";
129 plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ];
130 postRun = ''
131 systemctl reload httpd.service
132 '';
133 extraDomains = {
134 "www.aten.pro" = null;
135 };
136 };
125 # "connexionswing" = { 137 # "connexionswing" = {
126 # webroot = "/var/lib/acme/acme-challenge"; 138 # webroot = "/var/lib/acme/acme-challenge";
127 # email = "ismael@bouya.org"; 139 # email = "ismael@bouya.org";
@@ -190,6 +202,8 @@
190 connexionswing_prod = mypkgs.connexionswing_prod.phpFpm.pool; 202 connexionswing_prod = mypkgs.connexionswing_prod.phpFpm.pool;
191 ludivinecassal_dev = mypkgs.ludivinecassal_dev.phpFpm.pool; 203 ludivinecassal_dev = mypkgs.ludivinecassal_dev.phpFpm.pool;
192 ludivinecassal_prod = mypkgs.ludivinecassal_prod.phpFpm.pool; 204 ludivinecassal_prod = mypkgs.ludivinecassal_prod.phpFpm.pool;
205 aten_dev = mypkgs.aten_dev.phpFpm.pool;
206 aten_prod = mypkgs.aten_prod.phpFpm.pool;
193 nextcloud = mypkgs.nextcloud.phpFpm.pool; 207 nextcloud = mypkgs.nextcloud.phpFpm.pool;
194 mantisbt = mypkgs.mantisbt.phpFpm.pool; 208 mantisbt = mypkgs.mantisbt.phpFpm.pool;
195 }; 209 };
@@ -200,6 +214,8 @@
200 connexionswing_prod = mypkgs.connexionswing_prod.activationScript; 214 connexionswing_prod = mypkgs.connexionswing_prod.activationScript;
201 ludivinecassal_dev = mypkgs.ludivinecassal_dev.activationScript; 215 ludivinecassal_dev = mypkgs.ludivinecassal_dev.activationScript;
202 ludivinecassal_prod = mypkgs.ludivinecassal_prod.activationScript; 216 ludivinecassal_prod = mypkgs.ludivinecassal_prod.activationScript;
217 aten_dev = mypkgs.aten_dev.activationScript;
218 aten_prod = mypkgs.aten_prod.activationScript;
203 nextcloud = mypkgs.nextcloud.activationScript; 219 nextcloud = mypkgs.nextcloud.activationScript;
204 httpd = '' 220 httpd = ''
205 install -d -m 0755 /var/lib/acme/acme-challenge 221 install -d -m 0755 /var/lib/acme/acme-challenge
@@ -325,6 +341,8 @@
325 mypkgs.connexionswing_prod.apache.modules ++ 341 mypkgs.connexionswing_prod.apache.modules ++
326 mypkgs.ludivinecassal_dev.apache.modules ++ 342 mypkgs.ludivinecassal_dev.apache.modules ++
327 mypkgs.ludivinecassal_prod.apache.modules ++ 343 mypkgs.ludivinecassal_prod.apache.modules ++
344 mypkgs.aten_dev.apache.modules ++
345 mypkgs.aten_prod.apache.modules ++
328 mypkgs.ympd.apache.modules ++ 346 mypkgs.ympd.apache.modules ++
329 mypkgs.git.web.apache.modules ++ 347 mypkgs.git.web.apache.modules ++
330 mypkgs.mantisbt.apache.modules ++ 348 mypkgs.mantisbt.apache.modules ++
@@ -379,6 +397,21 @@
379 ]; 397 ];
380 }) 398 })
381 (withConf "eldiron" // { 399 (withConf "eldiron" // {
400 hostName = "dev.aten.pro";
401 documentRoot = mypkgs.aten_dev.webRoot;
402 extraConfig = builtins.concatStringsSep "\n" [
403 mypkgs.aten_dev.apache.vhostConf
404 ];
405 })
406 (withConf "aten" // {
407 hostName = "aten.pro";
408 serverAliases = [ "www.aten.pro" ];
409 documentRoot = mypkgs.aten_prod.webRoot;
410 extraConfig = builtins.concatStringsSep "\n" [
411 mypkgs.aten_prod.apache.vhostConf
412 ];
413 })
414 (withConf "eldiron" // {
382 hostName = "cloud.immae.eu"; 415 hostName = "cloud.immae.eu";
383 documentRoot = mypkgs.nextcloud.webRoot; 416 documentRoot = mypkgs.nextcloud.webRoot;
384 extraConfig = builtins.concatStringsSep "\n" [ 417 extraConfig = builtins.concatStringsSep "\n" [
diff --git a/virtual/packages.nix b/virtual/packages.nix
index 557bc6b..60a333a 100644
--- a/virtual/packages.nix
+++ b/virtual/packages.nix
@@ -2,6 +2,7 @@
2let 2let
3 connexionswing = callPackage ./packages/connexionswing.nix { inherit checkEnv fetchedGitPrivate; }; 3 connexionswing = callPackage ./packages/connexionswing.nix { inherit checkEnv fetchedGitPrivate; };
4 ludivinecassal = callPackage ./packages/ludivinecassal.nix { inherit checkEnv fetchedGitPrivate; }; 4 ludivinecassal = callPackage ./packages/ludivinecassal.nix { inherit checkEnv fetchedGitPrivate; };
5 aten = callPackage ./packages/aten.nix { inherit checkEnv fetchedGitPrivate; };
5 nextcloud = callPackage ./packages/nextcloud.nix { inherit checkEnv; }; 6 nextcloud = callPackage ./packages/nextcloud.nix { inherit checkEnv; };
6 adminer = callPackage ./packages/adminer.nix {}; 7 adminer = callPackage ./packages/adminer.nix {};
7 ympd = callPackage ./packages/ympd.nix {}; 8 ympd = callPackage ./packages/ympd.nix {};
@@ -15,6 +16,8 @@ in
15 connexionswing_prod = connexionswing { environment = "prod"; }; 16 connexionswing_prod = connexionswing { environment = "prod"; };
16 ludivinecassal_dev = ludivinecassal { environment = "dev"; }; 17 ludivinecassal_dev = ludivinecassal { environment = "dev"; };
17 ludivinecassal_prod = ludivinecassal { environment = "prod"; }; 18 ludivinecassal_prod = ludivinecassal { environment = "prod"; };
19 aten_dev = aten { environment = "dev"; };
20 aten_prod = aten { environment = "prod"; };
18 inherit nextcloud; 21 inherit nextcloud;
19 inherit mantisbt; 22 inherit mantisbt;
20 # FIXME: add buildbot 23 # FIXME: add buildbot
diff --git a/virtual/packages/aten.json b/virtual/packages/aten.json
new file mode 100644
index 0000000..53569b6
--- /dev/null
+++ b/virtual/packages/aten.json
@@ -0,0 +1,14 @@
1{
2 "tag": "b99537f-master",
3 "meta": {
4 "name": "aten",
5 "url": "gitolite@git.immae.eu:perso/Immae/Sites/Aten",
6 "branch": "master"
7 },
8 "git": {
9 "url": "gitolite@git.immae.eu:perso/Immae/Sites/Aten",
10 "rev": "b99537fdad41291afb4f1bb8b2e2aa4081c71fae",
11 "sha256": "15mlyik6zivxwry6zc906bqnivxhby27yr8kj4lg5n68pvb877dn",
12 "fetchSubmodules": true
13 }
14}
diff --git a/virtual/packages/aten.nix b/virtual/packages/aten.nix
new file mode 100644
index 0000000..016676f
--- /dev/null
+++ b/virtual/packages/aten.nix
@@ -0,0 +1,122 @@
1{ lib, checkEnv, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, yarn }:
2let
3 aten = { environment ? "dev" }: rec {
4 varPrefix = "ATEN";
5 varDir = "/var/lib/aten_${environment}";
6 envName= lib.strings.toUpper environment;
7 phpFpm = rec {
8 socket = "/var/run/phpfpm/aten-${environment}.sock";
9 pool = ''
10 listen = ${socket}
11 user = ${apache.user}
12 group = ${apache.group}
13 listen.owner = ${apache.user}
14 listen.group = ${apache.group}
15 php_admin_value[upload_max_filesize] = 20M
16 php_admin_value[post_max_size] = 20M
17 ;php_admin_flag[log_errors] = on
18 php_admin_value[open_basedir] = "${webappDir}:${varDir}:/tmp"
19 ${if environment == "dev" then ''
20 pm = ondemand
21 pm.max_children = 5
22 pm.process_idle_timeout = 60
23 env[SYMFONY_DEBUG_MODE] = "yes"
24 '' else ''
25 pm = dynamic
26 pm.max_children = 20
27 pm.start_servers = 2
28 pm.min_spare_servers = 1
29 pm.max_spare_servers = 3
30 ''}'';
31 };
32 apache = {
33 user = "wwwrun";
34 group = "wwwrun";
35 modules = [ "proxy_fcgi" ];
36 vhostConf =
37 assert checkEnv "NIXOPS_${varPrefix}_${envName}_SECRET";
38 assert checkEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL";
39 ''
40 <FilesMatch "\.php$">
41 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
42 </FilesMatch>
43
44 SetEnv APP_ENV "${environment}"
45 SetEnv APP_SECRET "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"}
46 SetEnv DATABASE_URL "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL"}
47
48 ${if environment == "dev" then ''
49 <Location />
50 Use LDAPConnect
51 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
52 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
53 </Location>
54
55 <Location /backend>
56 Use LDAPConnect
57 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
58 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
59 </Location>
60 '' else ''
61 <Location /backend>
62 Use LDAPConnect
63 Require ldap-group cn=aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
64 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
65 </Location>
66 ''}
67
68 <Directory ${webRoot}>
69 Options Indexes FollowSymLinks MultiViews Includes
70 AllowOverride All
71 Require all granted
72 DirectoryIndex index.php
73 FallbackResource /index.php
74 </Directory>
75 '';
76 };
77 activationScript = {
78 deps = [ "wrappers" ];
79 text = ''
80 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}
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
85 popd > /dev/null
86 echo -n "${webappDir}" > ${varDir}/currentWebappDir
87 fi
88 '';
89 };
90 webappDir = stdenv.mkDerivation (fetchedGitPrivate ./aten.json // rec {
91 # FIXME: can we do better than symlink?
92 # FIXME: initial sync
93 # FIXME: backup
94 # FIXME: usage statistics
95 buildPhase = ''
96 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
97 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
98 export APP_ENV="${environment}"
99 export DATABASE_URL="${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL"}"
100 export APP_SECRET="${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"}"
101
102 ${if environment == "dev" then ''
103 composer install
104 '' else ''
105 SYMFONY_ENV=prod composer install --no-dev
106 ''}
107 yarn install
108 yarn run encore production
109 rm -rf var
110 ln -sf ../../../../../${varDir} var
111 '';
112 installPhase = ''
113 cp -a . $out
114 '';
115 buildInputs = [
116 php git cacert phpPackages.composer yarn
117 ];
118 });
119 webRoot = "${webappDir}/public";
120 };
121in
122 aten