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