]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/connexionswing/integration.nix
Use attrs for secrets instead of lists
[perso/Immae/Config/Nix.git] / modules / private / websites / connexionswing / integration.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f8026b6e 2let
ab8f306d 3 secrets = config.myEnv.websites.connexionswing.integration;
d3452fc5 4 app = pkgs.callPackage ./app {
dcac3ec7 5 composerEnv = pkgs.composerEnv.override { php = pkgs.php72; };
d3452fc5
IB
6 environment = secrets.environment;
7 varDir = "/var/lib/connexionswing_integration";
8 secretsPath = config.secrets.fullPaths."websites/connexionswing/integration";
9 };
f8026b6e 10 cfg = config.myServices.websites.connexionswing.integration;
9f66adf4 11 pcfg = config.services.phpApplication;
f8026b6e
IB
12in {
13 options.myServices.websites.connexionswing.integration.enable = lib.mkEnableOption "enable Connexionswing's website in integration";
14
15 config = lib.mkIf cfg.enable {
d3452fc5
IB
16 services.duplyBackup.profiles.connexionswing_integration.rootDir = app.varDir;
17 services.phpApplication.apps.connexionswing_integration = {
9f66adf4
IB
18 websiteEnv = "integration";
19 httpdUser = config.services.httpd.Inte.user;
20 httpdGroup = config.services.httpd.Inte.group;
21 inherit (app) webRoot varDir;
22 varDirPaths = {
23 "medias" = "0700";
24 "uploads" = "0700";
25 "var" = "0700";
26 };
27 inherit app;
28 serviceDeps = [ "mysql.service" ];
29 preStartActions = [
30 "./bin/console --env=${app.environment} cache:clear --no-warmup"
31 ];
32 phpOpenbasedir = [ "/tmp" "/run/wrappers/bin/sendmail" ];
5400b9b6
IB
33 phpPool = {
34 "php_admin_value[upload_max_filesize]" = "20M";
35 "php_admin_value[post_max_size]" = "20M";
36 #"php_admin_flag[log_errors]" = "on";
37 "pm" = "ondemand";
38 "pm.max_children" = "5";
39 "pm.process_idle_timeout" = "60";
40 };
41 phpEnv = {
d3452fc5 42 SYMFONY_DEBUG_MODE = "\"yes\"";
5400b9b6 43 };
9f66adf4 44 phpWatchFiles = [
d3452fc5 45 config.secrets.fullPaths."websites/connexionswing/integration"
9f66adf4 46 ];
dcac3ec7 47 phpPackage = pkgs.php72;
f40f5b23 48 };
9f66adf4 49
4c4652aa
IB
50 secrets.keys."websites/connexionswing/integration" = {
51 user = config.services.httpd.Inte.user;
52 group = config.services.httpd.Inte.group;
53 permissions = "0400";
54 text = ''
55 # This file is auto-generated during the composer install
56 parameters:
57 database_host: ${secrets.mysql.host}
58 database_port: ${secrets.mysql.port}
59 database_name: ${secrets.mysql.database}
60 database_user: ${secrets.mysql.user}
61 database_password: ${secrets.mysql.password}
62 database_server_version: ${pkgs.mariadb.mysqlVersion}
63 mailer_transport: sendmail
64 mailer_host: null
65 mailer_user: null
66 mailer_password: null
67 subscription_email: ${secrets.email}
68 allow_robots: true
69 secret: ${secrets.secret}
70 '';
71 };
9f66adf4 72
d3452fc5
IB
73 services.websites.env.integration.vhostConfs.connexionswing_integration = {
74 certName = "integration";
f8026b6e
IB
75 addToCerts = true;
76 hosts = ["connexionswing.immae.eu" "sandetludo.immae.eu" ];
d3452fc5 77 root = pcfg.webappDirs.connexionswing_integration;
9f66adf4
IB
78 extraConfig = [
79 ''
80 <FilesMatch "\.php$">
d3452fc5 81 SetHandler "proxy:unix:${pcfg.phpListenPaths.connexionswing_integration}|fcgi://localhost"
9f66adf4
IB
82 </FilesMatch>
83
84 <Directory ${app.varDir}/medias>
85 Options FollowSymLinks
86 AllowOverride None
87 Require all granted
88 </Directory>
89
90 <Directory ${app.varDir}/uploads>
91 Options FollowSymLinks
92 AllowOverride None
93 Require all granted
94 </Directory>
95
96 <Location />
97 Use LDAPConnect
98 Require ldap-group cn=connexionswing.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
99 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://connexionswing.com\"></html>"
100 </Location>
101
d3452fc5 102 <Directory ${pcfg.webappDirs.connexionswing_integration}>
9f66adf4
IB
103 Options Indexes FollowSymLinks MultiViews Includes
104 AllowOverride None
105 Require all granted
106
107 DirectoryIndex app_dev.php
108
109 <IfModule mod_negotiation.c>
110 Options -MultiViews
111 </IfModule>
112
113 <IfModule mod_rewrite.c>
114 RewriteEngine On
115
116 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
117 RewriteRule ^(.*) - [E=BASE:%1]
118
119 # Maintenance script
120 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
121 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
122 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
123 ErrorDocument 503 /maintenance.php
124
125 # Sets the HTTP_AUTHORIZATION header removed by Apache
126 RewriteCond %{HTTP:Authorization} .
127 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
128
129 RewriteCond %{ENV:REDIRECT_STATUS} ^$
130 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
131
132 # If the requested filename exists, simply serve it.
133 # We only want to let Apache serve files and not directories.
134 RewriteCond %{REQUEST_FILENAME} -f
135 RewriteRule ^ - [L]
136
137 # Rewrite all other queries to the front controller.
138 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
139 </IfModule>
140
141 </Directory>
142 ''
143 ];
17f6eae9 144 };
f8026b6e
IB
145 };
146}