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