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