aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/connexionswing/integration.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-06-02 22:53:54 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-06-02 22:53:54 +0200
commit9f66adf4372a3b1c859dc053489f727aa360077e (patch)
tree1f1333f2fe59f5e77a6737c42dcd379f9c587a5c /modules/private/websites/connexionswing/integration.nix
parent1594c8da6fbb4ffa09ab970fb887cea61c572f60 (diff)
downloadNix-9f66adf4372a3b1c859dc053489f727aa360077e.tar.gz
Nix-9f66adf4372a3b1c859dc053489f727aa360077e.tar.zst
Nix-9f66adf4372a3b1c859dc053489f727aa360077e.zip
Move integration php applications to dedicated module
Diffstat (limited to 'modules/private/websites/connexionswing/integration.nix')
-rw-r--r--modules/private/websites/connexionswing/integration.nix154
1 files changed, 127 insertions, 27 deletions
diff --git a/modules/private/websites/connexionswing/integration.nix b/modules/private/websites/connexionswing/integration.nix
index 795d532..2ceaffa 100644
--- a/modules/private/websites/connexionswing/integration.nix
+++ b/modules/private/websites/connexionswing/integration.nix
@@ -1,40 +1,140 @@
1{ lib, pkgs, config, myconfig, ... }: 1{ lib, pkgs, config, myconfig, ... }:
2let 2let
3 connexionswing = pkgs.callPackage ./builder.nix { 3 secrets = myconfig.env.websites.connexionswing.integration;
4 inherit (pkgs.webapps) connexionswing; 4 app = pkgs.webapps.connexionswing.override { environment = secrets.environment; };
5 config = myconfig.env.websites.connexionswing.integration;
6 apacheUser = config.services.httpd.Inte.user;
7 apacheGroup = config.services.httpd.Inte.group;
8 };
9
10 cfg = config.myServices.websites.connexionswing.integration; 5 cfg = config.myServices.websites.connexionswing.integration;
6 pcfg = config.services.phpApplication;
11in { 7in {
12 options.myServices.websites.connexionswing.integration.enable = lib.mkEnableOption "enable Connexionswing's website in integration"; 8 options.myServices.websites.connexionswing.integration.enable = lib.mkEnableOption "enable Connexionswing's website in integration";
13 9
14 config = lib.mkIf cfg.enable { 10 config = lib.mkIf cfg.enable {
15 secrets.keys = connexionswing.keys; 11 services.phpApplication.apps.connexionswing_dev = {
16 systemd.services.phpfpm-connexionswing_dev.after = lib.mkAfter connexionswing.phpFpm.serviceDeps; 12 websiteEnv = "integration";
17 systemd.services.phpfpm-connexionswing_dev.wants = connexionswing.phpFpm.serviceDeps; 13 httpdUser = config.services.httpd.Inte.user;
18 systemd.services.phpfpm-connexionswing_dev.preStart = lib.mkAfter connexionswing.phpFpm.preStart; 14 httpdGroup = config.services.httpd.Inte.group;
19 services.phpfpm.pools.connexionswing_dev = { 15 inherit (app) webRoot varDir;
20 listen = connexionswing.phpFpm.socket; 16 varDirPaths = {
21 extraConfig = connexionswing.phpFpm.pool; 17 "medias" = "0700";
22 phpOptions = config.services.phpfpm.phpOptions + connexionswing.phpFpm.phpConfig; 18 "uploads" = "0700";
19 "var" = "0700";
20 };
21 inherit app;
22 serviceDeps = [ "mysql.service" ];
23 preStartActions = [
24 "./bin/console --env=${app.environment} cache:clear --no-warmup"
25 ];
26 phpOpenbasedir = [ "/tmp" "/run/wrappers/bin/sendmail" ];
27 phpPool = ''
28 php_admin_value[upload_max_filesize] = 20M
29 php_admin_value[post_max_size] = 20M
30 ;php_admin_flag[log_errors] = on
31 pm = ondemand
32 pm.max_children = 5
33 pm.process_idle_timeout = 60
34 env[SYMFONY_DEBUG_MODE] = "yes"
35 '';
36 phpWatchFiles = [
37 config.secrets.fullPaths."webapps/${app.environment}-connexionswing"
38 ];
23 }; 39 };
24 system.activationScripts.connexionswing_dev = connexionswing.activationScript; 40
25 myServices.websites.webappDirs."${connexionswing.apache.webappName}" = connexionswing.app.webRoot; 41 secrets.keys = [
26 services.websites.env.integration.modules = connexionswing.apache.modules; 42 {
27 services.websites.env.integration.vhostConfs.connexionswing = { 43 dest = "webapps/${app.environment}-connexionswing";
28 certName = "eldiron"; 44 user = config.services.httpd.Inte.user;
45 group = config.services.httpd.Inte.group;
46 permissions = "0400";
47 text = ''
48 # This file is auto-generated during the composer install
49 parameters:
50 database_host: ${secrets.mysql.host}
51 database_port: ${secrets.mysql.port}
52 database_name: ${secrets.mysql.name}
53 database_user: ${secrets.mysql.user}
54 database_password: ${secrets.mysql.password}
55 database_server_version: ${pkgs.mariadb.mysqlVersion}
56 mailer_transport: sendmail
57 mailer_host: null
58 mailer_user: null
59 mailer_password: null
60 subscription_email: ${secrets.email}
61 allow_robots: true
62 secret: ${secrets.secret}
63 '';
64 }
65 ];
66
67 services.websites.env.integration.vhostConfs.connexionswing_dev = {
68 certName = "eldiron";
29 addToCerts = true; 69 addToCerts = true;
30 hosts = ["connexionswing.immae.eu" "sandetludo.immae.eu" ]; 70 hosts = ["connexionswing.immae.eu" "sandetludo.immae.eu" ];
31 root = connexionswing.apache.root; 71 root = pcfg.webappDirs.connexionswing_dev;
32 extraConfig = [ connexionswing.apache.vhostConf ]; 72 extraConfig = [
33 }; 73 ''
34 services.filesWatcher.phpfpm-connexionswing_dev = { 74 <FilesMatch "\.php$">
35 restart = true; 75 SetHandler "proxy:unix:${pcfg.phpListenPaths.connexionswing_dev}|fcgi://localhost"
36 paths = [ "/var/secrets/webapps/${connexionswing.app.environment}-connexionswing" ]; 76 </FilesMatch>
77
78 <Directory ${app.varDir}/medias>
79 Options FollowSymLinks
80 AllowOverride None
81 Require all granted
82 </Directory>
83
84 <Directory ${app.varDir}/uploads>
85 Options FollowSymLinks
86 AllowOverride None
87 Require all granted
88 </Directory>
89
90 <Location />
91 Use LDAPConnect
92 Require ldap-group cn=connexionswing.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
93 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://connexionswing.com\"></html>"
94 </Location>
95
96 <Directory ${pcfg.webappDirs.connexionswing_dev}>
97 Options Indexes FollowSymLinks MultiViews Includes
98 AllowOverride None
99 Require all granted
100
101 DirectoryIndex app_dev.php
102
103 <IfModule mod_negotiation.c>
104 Options -MultiViews
105 </IfModule>
106
107 <IfModule mod_rewrite.c>
108 RewriteEngine On
109
110 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
111 RewriteRule ^(.*) - [E=BASE:%1]
112
113 # Maintenance script
114 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
115 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
116 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
117 ErrorDocument 503 /maintenance.php
118
119 # Sets the HTTP_AUTHORIZATION header removed by Apache
120 RewriteCond %{HTTP:Authorization} .
121 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
122
123 RewriteCond %{ENV:REDIRECT_STATUS} ^$
124 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
125
126 # If the requested filename exists, simply serve it.
127 # We only want to let Apache serve files and not directories.
128 RewriteCond %{REQUEST_FILENAME} -f
129 RewriteRule ^ - [L]
130
131 # Rewrite all other queries to the front controller.
132 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
133 </IfModule>
134
135 </Directory>
136 ''
137 ];
37 }; 138 };
38 }; 139 };
39} 140}
40