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