]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/isabelle/aten_integration.nix
Move devtools to other place
[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 webRoot = "/var/lib/ftp/immae/aten/public";
5 cfg = config.myServices.websites.isabelle.aten_integration;
6 pcfg = config.services.phpApplication;
7 in {
8 options.myServices.websites.isabelle.aten_integration.enable = lib.mkEnableOption "enable Aten's website in integration";
9
10 config = lib.mkIf cfg.enable {
11 services.duplyBackup.profiles.isabelle_aten_integration.rootDir = app.varDir;
12 services.phpApplication.apps.isabelle_aten_integration = {
13 websiteEnv = "integration";
14 httpdUser = config.services.httpd.Inte.user;
15 httpdGroup = config.services.httpd.Inte.group;
16 httpdWatchFiles = [
17 config.secrets.fullPaths."websites/isabelle/aten_integration"
18 ];
19 inherit webRoot;
20 varDir = "/var/lib/ftp/immae/aten_var";
21 app = "/var/lib/ftp/immae/aten";
22 serviceDeps = [ "postgresql.service" ];
23 preStartActions = [
24 "APP_ENV=dev ./bin/console --env=dev cache:clear --no-warmup"
25 ];
26 phpOpenbasedir = [ "/tmp" ];
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 = {
36 SYMFONY_DEBUG_MODE = "\"yes\"";
37 };
38 phpPackage = pkgs.php72;
39 };
40
41 secrets.keys."websites/isabelle/aten_integration" = {
42 user = config.services.httpd.Inte.user;
43 group = config.services.httpd.Inte.group;
44 permissions = "0400";
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 ''
51 SetEnv APP_ENV "dev"
52 SetEnv APP_SECRET "${secrets.secret}"
53 SetEnv DATABASE_URL "${psql_url}"
54 '';
55 };
56 services.websites.env.integration.vhostConfs.isabelle_aten_integration = {
57 certName = "integration";
58 addToCerts = true;
59 hosts = [ "dev.aten.pro" ];
60 root = webRoot;
61 extraConfig = [
62 ''
63 <FilesMatch "\.php$">
64 SetHandler "proxy:unix:${pcfg.phpListenPaths.isabelle_aten_integration}|fcgi://localhost"
65 </FilesMatch>
66
67 Include ${config.secrets.fullPaths."websites/isabelle/aten_integration"}
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
81 <Directory ${webRoot}>
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 ];
90 };
91 };
92 }