]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/chloe/integration.nix
Move devtools to other place
[perso/Immae/Config/Nix.git] / modules / private / websites / chloe / integration.nix
1 { lib, pkgs, config, ... }:
2 let
3 apacheUser = config.services.httpd.Inte.user;
4 apacheGroup = config.services.httpd.Inte.group;
5 ccfg = config.myEnv.websites.chloe.integration;
6 webRoot = "/var/lib/ftp/immae/chloe";
7 varDir = "/var/lib/ftp/immae/chloe_var";
8 cfg = config.myServices.websites.chloe.integration;
9 in {
10 options.myServices.websites.chloe.integration.enable = lib.mkEnableOption "enable Chloe's website in integration";
11
12 config = lib.mkIf cfg.enable {
13 services.duplyBackup.profiles.chloe_integration.rootDir = app.varDir;
14 secrets.keys."websites/chloe/integration" = {
15 user = apacheUser;
16 group = apacheGroup;
17 permissions = "0400";
18 text = ''
19 SetEnv SPIP_CONFIG_DIR "${./config}"
20 SetEnv SPIP_VAR_DIR "${varDir}"
21 SetEnv SPIP_SITE "chloe-dev"
22 SetEnv SPIP_LDAP_BASE "dc=immae,dc=eu"
23 SetEnv SPIP_LDAP_HOST "ldaps://ldap.immae.eu"
24 SetEnv SPIP_LDAP_SEARCH_DN "${ccfg.ldap.dn}"
25 SetEnv SPIP_LDAP_SEARCH_PW "${ccfg.ldap.password}"
26 SetEnv SPIP_LDAP_SEARCH "${ccfg.ldap.filter}"
27 SetEnv SPIP_MYSQL_HOST "${ccfg.mysql.host}"
28 SetEnv SPIP_MYSQL_PORT "${ccfg.mysql.port}"
29 SetEnv SPIP_MYSQL_DB "${ccfg.mysql.database}"
30 SetEnv SPIP_MYSQL_USER "${ccfg.mysql.user}"
31 SetEnv SPIP_MYSQL_PASSWORD "${ccfg.mysql.password}"
32 '';
33 };
34 systemd.services.phpfpm-chloe_integration.after = lib.mkAfter [ "mysql.service" ];
35 systemd.services.phpfpm-chloe_integration.wants = [ "mysql.service" ];
36 services.phpfpm.pools.chloe_integration = {
37 user = config.services.httpd.Inte.user;
38 group = config.services.httpd.Inte.group;
39 settings = {
40 "listen.owner" = apacheUser;
41 "listen.group" = apacheGroup;
42 "php_admin_value[upload_max_filesize]" = "20M";
43 "php_admin_value[post_max_size]" = "20M";
44 # "php_admin_flag[log_errors]" = "on";
45 "php_admin_value[open_basedir]" = "${../../../../pkgs/webapps/spip/spip_mes_options.php}:${./config}:${webRoot}:${varDir}:/tmp";
46 "php_admin_value[session.save_path]" = "${varDir}/phpSessions";
47 "pm" = "ondemand";
48 "pm.max_children" = "5";
49 "pm.process_idle_timeout" = "60";
50 };
51 phpPackage = pkgs.php72;
52 };
53 system.activationScripts.chloe_integration = {
54 deps = [ "wrappers" ];
55 text = ''
56 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${varDir} ${varDir}/IMG ${varDir}/tmp ${varDir}/local
57 install -m 0750 -o ${apacheUser} -g ${apacheGroup} -d ${varDir}/phpSessions
58 '';
59 };
60 services.websites.env.integration.modules = [ "proxy_fcgi" ];
61 services.websites.env.integration.vhostConfs.chloe_integration = {
62 certName = "integration";
63 addToCerts = true;
64 hosts = ["chloe.immae.eu" ];
65 root = webRoot;
66 extraConfig = [
67 ''
68 Include ${config.secrets.fullPaths."websites/chloe/integration"}
69
70 RewriteEngine On
71
72 <FilesMatch "\.php$">
73 SetHandler "proxy:unix:${config.services.phpfpm.pools.chloe_integration.socket}|fcgi://localhost"
74 </FilesMatch>
75
76 <Directory ${webRoot}>
77 DirectoryIndex index.php index.htm index.html
78 Options -Indexes +FollowSymLinks +MultiViews +Includes
79 Include ${webRoot}/htaccess.txt
80
81 AllowOverride AuthConfig FileInfo Limit
82 Require all granted
83 </Directory>
84
85 <DirectoryMatch "${webRoot}/squelettes">
86 Require all denied
87 </DirectoryMatch>
88
89 <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$">
90 Require all denied
91 </FilesMatch>
92
93 <Location />
94 Use LDAPConnect
95 Require ldap-group cn=chloe.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
96 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://osteopathe-cc.fr\"></html>"
97 </Location>
98 ''
99 ];
100 };
101 services.websites.env.integration.watchPaths = [
102 config.secrets.fullPaths."websites/chloe/integration"
103 ];
104 };
105 }