]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - nixops/modules/websites/tools/git/mantisbt/mantisbt.nix
Cleanup php session directories
[perso/Immae/Config/Nix.git] / nixops / modules / websites / tools / git / mantisbt / mantisbt.nix
CommitLineData
9d90e7e2 1{ lib, env, writeText, stdenv, fetchurl, fetchedGithub }:
50d8fa14 2let
50d8fa14
IB
3 mantisbt = let
4 plugins = {
5 slack = stdenv.mkDerivation (fetchedGithub ./mantisbt-plugin-slack.json // rec {
6 installPhase = ''
7 sed -i -e "s/return '@' . \\\$username;/return \\\$username;/" Slack.php
8 cp -a . $out
9 '';
10 });
11 source-integration = stdenv.mkDerivation (fetchedGithub ./mantisbt-plugin-source-integration.json // rec {
12 installPhase = ''
13 mkdir $out
14 patch -p1 < ${./mantisbt-plugin-source-integration_Source.API.php.diff}
15 cp -a Source* $out/
16 '';
17 });
18 };
19 in rec {
ec2a5ffb
IB
20 keys."tools-mantisbt" = {
21 destDir = "/run/keys/webapps";
22 user = apache.user;
23 group = apache.group;
85f5ed68 24 permissions = "0400";
ec2a5ffb
IB
25 text = ''
26 <?php
27 $g_hostname = '${env.postgresql.socket}';
28 $g_db_username = '${env.postgresql.user}';
29 $g_db_password = '${env.postgresql.password}';
30 $g_database_name = '${env.postgresql.database}';
31 $g_db_type = 'pgsql';
32 $g_crypto_master_salt = '${env.master_salt}';
33 $g_allow_signup = OFF;
34 $g_allow_anonymous_login = ON;
35 $g_anonymous_account = 'anonymous';
50d8fa14 36
ec2a5ffb
IB
37 $g_phpMailer_method = PHPMAILER_METHOD_SENDMAIL;
38 $g_smtp_host = 'localhost';
39 $g_smtp_username = ''';
40 $g_smtp_password = ''';
41 $g_webmaster_email = 'mantisbt@tools.immae.eu';
42 $g_from_email = 'mantisbt@tools.immae.eu';
43 $g_return_path_email = 'mantisbt@tools.immae.eu';
44 $g_from_name = 'Mantis Bug Tracker at git.immae.eu';
45 $g_email_receive_own = OFF;
46 # --- LDAP ---
47 $g_login_method = LDAP;
48 $g_ldap_protocol_version = 3;
49 $g_ldap_server = 'ldaps://ldap.immae.eu:636';
50 $g_ldap_root_dn = 'ou=users,dc=immae,dc=eu';
51 $g_ldap_bind_dn = 'cn=mantisbt,ou=services,dc=immae,dc=eu';
52 $g_ldap_bind_passwd = '${env.ldap.password}';
53 $g_use_ldap_email = ON;
54 $g_use_ldap_realname = ON;
55 $g_ldap_uid_field = 'uid';
56 $g_ldap_realname_field = 'cn';
57 $g_ldap_organization = '(memberOf=cn=users,cn=mantisbt,ou=services,dc=immae,dc=eu)';
50d8fa14 58 '';
ec2a5ffb 59 };
50d8fa14
IB
60 webRoot = stdenv.mkDerivation rec {
61 name = "mantisbt-${version}";
62 version = "2.11.1";
63 src = fetchurl {
64 url = "https://downloads.sourceforge.net/project/mantisbt/mantis-stable/${version}/${name}.tar.gz";
65 sha256 = "0jnrqz6r2hf53v0k1lh3il7hlfiphn61r9wgg6mzyywkjxwq07md";
66 };
67 patches = [
10889174
IB
68 ./patches/bug_report.php.diff
69 ./patches/bug_report_page.php.diff
70 ./patches/bugnote_add.php.diff
71 ./patches/bugnote_add_inc.php.diff
50d8fa14
IB
72 ];
73 installPhase = ''
74 cp -a . $out
ec2a5ffb 75 ln -s /run/keys/webapps/tools-mantisbt $out/config/config_inc.php
50d8fa14
IB
76 ln -s ${plugins.slack} $out/plugins/Slack
77 ln -s ${plugins.source-integration}/Source* $out/plugins/
78 '';
79 };
a95ab089 80 apache = rec {
50d8fa14
IB
81 user = "wwwrun";
82 group = "wwwrun";
83 modules = [ "proxy_fcgi" ];
a95ab089
IB
84 webappName = "tools_mantisbt";
85 root = "/run/current-system/webapps/${webappName}";
50d8fa14 86 vhostConf = ''
a95ab089
IB
87 Alias /mantisbt "${root}"
88 <Directory "${root}">
50d8fa14
IB
89 DirectoryIndex index.php
90 <FilesMatch "\.php$">
91 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
92 </FilesMatch>
93
94 AllowOverride All
95 Options FollowSymlinks
96 Require all granted
97 </Directory>
a95ab089 98 <Directory "${root}/admin">
50d8fa14
IB
99 #Reenable during upgrade
100 Require all denied
101 </Directory>
102 '';
103 };
104 phpFpm = rec {
ec2a5ffb 105 serviceDeps = [ "postgresql.service" "openldap.service" "tools-mantisbt-key.service" ];
50d8fa14 106 basedir = builtins.concatStringsSep ":" (
ec2a5ffb 107 [ webRoot "/run/keys/webapps/tools-mantisbt" ]
5c101474 108 ++ lib.attrsets.mapAttrsToList (name: value: value) plugins);
50d8fa14
IB
109 socket = "/var/run/phpfpm/mantisbt.sock";
110 pool = ''
111 listen = ${socket}
112 user = ${apache.user}
113 group = ${apache.group}
114 listen.owner = ${apache.user}
115 listen.group = ${apache.group}
116 pm = ondemand
117 pm.max_children = 60
118 pm.process_idle_timeout = 60
119
120 php_admin_value[upload_max_filesize] = 5000000
121
b7d2d4e3 122 php_admin_value[open_basedir] = "${basedir}:/tmp:/var/lib/php/sessions/mantisbt"
c8e019b6 123 php_admin_value[session.save_path] = "/var/lib/php/sessions/mantisbt"
50d8fa14
IB
124 '';
125 };
126 };
ec2a5ffb 127in
50d8fa14 128 mantisbt