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