aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/tellesflorian
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-18 10:49:00 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-18 10:49:00 +0200
commitf8026b6e4c869aa108f6361c8ccd50890657994d (patch)
tree57cb311e520933bd2ab6ccbae05f2913799eb49e /nixops/modules/websites/tellesflorian
parent4aac110f17f0528d90510eec00c9a8df60bcf04f (diff)
downloadNix-f8026b6e4c869aa108f6361c8ccd50890657994d.tar.gz
Nix-f8026b6e4c869aa108f6361c8ccd50890657994d.tar.zst
Nix-f8026b6e4c869aa108f6361c8ccd50890657994d.zip
Move personal websites to modules
Diffstat (limited to 'nixops/modules/websites/tellesflorian')
-rw-r--r--nixops/modules/websites/tellesflorian/default.nix40
-rw-r--r--nixops/modules/websites/tellesflorian/tellesflorian.nix154
2 files changed, 0 insertions, 194 deletions
diff --git a/nixops/modules/websites/tellesflorian/default.nix b/nixops/modules/websites/tellesflorian/default.nix
deleted file mode 100644
index bbbde07..0000000
--- a/nixops/modules/websites/tellesflorian/default.nix
+++ /dev/null
@@ -1,40 +0,0 @@
1{ lib, pkgs, config, myconfig, ... }:
2let
3 adminer = pkgs.callPackage ../commons/adminer.nix {};
4
5 tellesflorian_dev = pkgs.callPackage ./tellesflorian.nix {
6 inherit (pkgs.webapps) tellesflorian;
7 config = myconfig.env.websites.tellesflorian.integration;
8 };
9
10 cfg = config.services.myWebsites.TellesFlorian;
11in {
12 options.services.myWebsites.TellesFlorian = {
13 integration = {
14 enable = lib.mkEnableOption "enable Florian Telles's website in integration";
15 };
16 };
17
18 config = lib.mkIf cfg.integration.enable {
19 secrets.keys = tellesflorian_dev.keys;
20 services.myPhpfpm.preStart.tellesflorian_dev = tellesflorian_dev.phpFpm.preStart;
21 services.myPhpfpm.serviceDependencies.tellesflorian_dev = tellesflorian_dev.phpFpm.serviceDeps;
22 services.myPhpfpm.poolConfigs.tellesflorian_dev = tellesflorian_dev.phpFpm.pool;
23 system.activationScripts.tellesflorian_dev = tellesflorian_dev.activationScript;
24 system.extraSystemBuilderCmds = ''
25 mkdir -p $out/webapps
26 ln -s ${tellesflorian_dev.app.webRoot} $out/webapps/${tellesflorian_dev.apache.webappName}
27 '';
28 services.websites.integration.modules = adminer.apache.modules ++ tellesflorian_dev.apache.modules;
29 services.websites.integration.vhostConfs.tellesflorian = {
30 certName = "eldiron";
31 addToCerts = true;
32 hosts = ["app.tellesflorian.com" ];
33 root = tellesflorian_dev.apache.root;
34 extraConfig = [
35 tellesflorian_dev.apache.vhostConf
36 adminer.apache.vhostConf
37 ];
38 };
39 };
40}
diff --git a/nixops/modules/websites/tellesflorian/tellesflorian.nix b/nixops/modules/websites/tellesflorian/tellesflorian.nix
deleted file mode 100644
index 5955431..0000000
--- a/nixops/modules/websites/tellesflorian/tellesflorian.nix
+++ /dev/null
@@ -1,154 +0,0 @@
1{ tellesflorian, config }:
2rec {
3 app = tellesflorian.override { inherit (config) environment; };
4 keys = [
5 {
6 dest = "webapps/${app.environment}-tellesflorian-passwords";
7 user = apache.user;
8 group = apache.group;
9 permissions = "0400";
10 text = ''
11 invite:${config.invite_passwords}
12 '';
13 }
14 {
15 dest = "webapps/${app.environment}-tellesflorian";
16 user = apache.user;
17 group = apache.group;
18 permissions = "0400";
19 text = ''
20 # This file is auto-generated during the composer install
21 parameters:
22 database_host: ${config.mysql.host}
23 database_port: ${config.mysql.port}
24 database_name: ${config.mysql.name}
25 database_user: ${config.mysql.user}
26 database_password: ${config.mysql.password}
27 mailer_transport: smtp
28 mailer_host: 127.0.0.1
29 mailer_user: null
30 mailer_password: null
31 secret: ${config.secret}
32 '';
33 }
34 ];
35 phpFpm = rec {
36 preStart = ''
37 if [ ! -f "${app.varDir}/currentWebappDir" -o \
38 ! -f "${app.varDir}/currentKey" -o \
39 "${app}" != "$(cat ${app.varDir}/currentWebappDir 2>/dev/null)" ] \
40 || ! sha512sum -c --status ${app.varDir}/currentKey; then
41 pushd ${app} > /dev/null
42 /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=${app.environment} cache:clear --no-warmup
43 popd > /dev/null
44 echo -n "${app}" > ${app.varDir}/currentWebappDir
45 sha512sum /var/secrets/webapps/${app.environment}-tellesflorian > ${app.varDir}/currentKey
46 fi
47 '';
48 serviceDeps = [ "mysql.service" ];
49 socket = "/var/run/phpfpm/floriantelles-${app.environment}.sock";
50 pool = ''
51 listen = ${socket}
52 user = ${apache.user}
53 group = ${apache.group}
54 listen.owner = ${apache.user}
55 listen.group = ${apache.group}
56 php_admin_value[upload_max_filesize] = 20M
57 php_admin_value[post_max_size] = 20M
58 ;php_admin_flag[log_errors] = on
59 php_admin_value[open_basedir] = "/var/secrets/webapps/${app.environment}-tellesflorian:${app}:${app.varDir}:/tmp"
60 php_admin_value[session.save_path] = "${app.varDir}/phpSessions"
61 ${if app.environment == "dev" then ''
62 pm = ondemand
63 pm.max_children = 5
64 pm.process_idle_timeout = 60
65 env[SYMFONY_DEBUG_MODE] = "yes"
66 '' else ''
67 pm = dynamic
68 pm.max_children = 20
69 pm.start_servers = 2
70 pm.min_spare_servers = 1
71 pm.max_spare_servers = 3
72 ''}'';
73 };
74 apache = rec {
75 user = "wwwrun";
76 group = "wwwrun";
77 modules = [ "proxy_fcgi" ];
78 webappName = "florian_${app.environment}";
79 root = "/run/current-system/webapps/${webappName}";
80 vhostConf = ''
81 <FilesMatch "\.php$">
82 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
83 </FilesMatch>
84
85 ${if app.environment == "dev" then ''
86 <Location />
87 AuthBasicProvider file ldap
88 Use LDAPConnect
89 Require ldap-group cn=app.tellesflorian.com,cn=httpd,ou=services,dc=immae,dc=eu
90
91 AuthUserFile "/var/secrets/webapps/${app.environment}-tellesflorian-passwords"
92 Require user "invite"
93
94 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://tellesflorian.com\"></html>"
95 </Location>
96
97 <Directory ${root}>
98 Options Indexes FollowSymLinks MultiViews Includes
99 AllowOverride None
100 Require all granted
101
102 DirectoryIndex app_dev.php
103
104 <IfModule mod_negotiation.c>
105 Options -MultiViews
106 </IfModule>
107
108 <IfModule mod_rewrite.c>
109 RewriteEngine On
110
111 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
112 RewriteRule ^(.*) - [E=BASE:%1]
113
114 # Maintenance script
115 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
116 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
117 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
118 ErrorDocument 503 /maintenance.php
119
120 # Sets the HTTP_AUTHORIZATION header removed by Apache
121 RewriteCond %{HTTP:Authorization} .
122 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
123
124 RewriteCond %{ENV:REDIRECT_STATUS} ^$
125 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
126
127 # If the requested filename exists, simply serve it.
128 # We only want to let Apache serve files and not directories.
129 RewriteCond %{REQUEST_FILENAME} -f
130 RewriteRule ^ - [L]
131
132 # Rewrite all other queries to the front controller.
133 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
134 </IfModule>
135
136 </Directory>
137 '' else ''
138 <Directory ${root}>
139 Options Indexes FollowSymLinks MultiViews Includes
140 AllowOverride All
141 Require all granted
142 </Directory>
143 ''}
144 '';
145 };
146 activationScript = {
147 deps = [ "wrappers" ];
148 text = ''
149 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${app.varDir} \
150 ${app.varDir}/var
151 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${app.varDir}/phpSessions
152 '';
153 };
154}