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