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