]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/isabelle/aten_integration.nix
61c35cc42fa6fec14bfbd6ae05fc5d4e9187dade
[perso/Immae/Config/Nix.git] / modules / private / websites / isabelle / aten_integration.nix
1 { lib, pkgs, config, ... }:
2 let
3 secrets = config.myEnv.websites.isabelle.aten_integration;
4 app = pkgs.callPackage ./aten_app {
5 environment = secrets.environment;
6 varDir = "/var/lib/isabelle_aten_integration";
7 };
8 cfg = config.myServices.websites.isabelle.aten_integration;
9 pcfg = config.services.phpApplication;
10 in {
11 options.myServices.websites.isabelle.aten_integration.enable = lib.mkEnableOption "enable Aten's website in integration";
12
13 config = lib.mkIf cfg.enable {
14 services.duplyBackup.profiles.isabelle_aten_integration.rootDir = app.varDir;
15 services.phpApplication.apps.isabelle_aten_integration = {
16 websiteEnv = "integration";
17 httpdUser = config.services.httpd.Inte.user;
18 httpdGroup = config.services.httpd.Inte.group;
19 httpdWatchFiles = [
20 config.secrets.fullPaths."websites/isabelle/aten_integration"
21 ];
22 inherit (app) webRoot varDir;
23 inherit app;
24 serviceDeps = [ "postgresql.service" ];
25 preStartActions = [
26 "APP_ENV=${app.environment} ./bin/console --env=${app.environment} cache:clear --no-warmup"
27 ];
28 phpOpenbasedir = [ "/tmp" ];
29 phpPool = {
30 "php_admin_value[upload_max_filesize]" = "20M";
31 "php_admin_value[post_max_size]" = "20M";
32 #"php_admin_flag[log_errors]" = "on";
33 "pm" = "ondemand";
34 "pm.max_children" = "5";
35 "pm.process_idle_timeout" = "60";
36 };
37 phpEnv = {
38 SYMFONY_DEBUG_MODE = "\"yes\"";
39 };
40 };
41
42 secrets.keys = [{
43 dest = "websites/isabelle/aten_integration";
44 user = config.services.httpd.Inte.user;
45 group = config.services.httpd.Inte.group;
46 permissions = "0400";
47 text = let
48 # cf:
49 # https://secure.php.net/manual/fr/function.parse-url.php
50 # vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php#parseDatabaseUrlQuery
51 psql_url = with secrets.postgresql; "pdo-pgsql://${user}:${password}@invalid:${port}/${database}?host=${socket}";
52 in ''
53 SetEnv APP_ENV "${app.environment}"
54 SetEnv APP_SECRET "${secrets.secret}"
55 SetEnv DATABASE_URL "${psql_url}"
56 '';
57 }];
58 services.websites.env.integration.vhostConfs.isabelle_aten_integration = {
59 certName = "integration";
60 addToCerts = true;
61 hosts = [ "dev.aten.pro" ];
62 root = pcfg.webappDirs.isabelle_aten_integration;
63 extraConfig = [
64 ''
65 <FilesMatch "\.php$">
66 SetHandler "proxy:unix:${pcfg.phpListenPaths.isabelle_aten_integration}|fcgi://localhost"
67 </FilesMatch>
68
69 Include ${config.secrets.fullPaths."websites/isabelle/aten_integration"}
70
71 <Location />
72 Use LDAPConnect
73 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
74 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
75 </Location>
76
77 <Location /backend>
78 Use LDAPConnect
79 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
80 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
81 </Location>
82
83 <Directory ${pcfg.webappDirs.isabelle_aten_integration}>
84 Options Indexes FollowSymLinks MultiViews Includes
85 AllowOverride All
86 Require all granted
87 DirectoryIndex index.php
88 FallbackResource /index.php
89 </Directory>
90 ''
91 ];
92 };
93 };
94 }