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