]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/modules/websites/tools/git/mantisbt/mantisbt.nix
bc2ff3a1127f1cc0f37a6b02794bbb246383688e
[perso/Immae/Config/Nix.git] / nixops / modules / websites / tools / git / mantisbt / mantisbt.nix
1 { lib, env, writeText, stdenv, fetchurl, fetchedGithub }:
2 let
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 {
20 config =
21 writeText "config_inc.php" ''
22 <?php
23 $g_hostname = 'db-1.immae.eu';
24 $g_db_username = 'mantisbt';
25 $g_db_password = '${env.postgresql.password}';
26 $g_database_name = 'mantisbt';
27 $g_db_type = 'pgsql';
28 $g_crypto_master_salt = '${env.master_salt}';
29 $g_allow_signup = OFF;
30 $g_allow_anonymous_login = ON;
31 $g_anonymous_account = 'anonymous';
32
33 $g_phpMailer_method = PHPMAILER_METHOD_SMTP;
34 $g_smtp_host = 'mail.immae.eu';
35 $g_smtp_username = ''';
36 $g_smtp_password = ''';
37 $g_webmaster_email = 'webmaster@immae.eu';
38 $g_from_email = 'noreply@immae.eu';
39 $g_return_path_email = 'webmaster@immae.eu';
40 $g_from_name = 'Mantis Bug Tracker at immae.eu';
41 $g_email_receive_own = OFF;
42 # --- LDAP ---
43 $g_login_method = LDAP;
44 $g_ldap_protocol_version = 3;
45 $g_ldap_server = 'ldaps://ldap.immae.eu:636';
46 $g_ldap_root_dn = 'ou=users,dc=immae,dc=eu';
47 $g_ldap_bind_dn = 'cn=mantisbt,ou=services,dc=immae,dc=eu';
48 $g_ldap_bind_passwd = '${env.ldap.password}';
49 $g_use_ldap_email = ON;
50 $g_use_ldap_realname = ON;
51 $g_ldap_uid_field = 'uid';
52 $g_ldap_realname_field = 'cn';
53 $g_ldap_organization = '(memberOf=cn=users,cn=mantisbt,ou=services,dc=immae,dc=eu)';
54 '';
55 webRoot = stdenv.mkDerivation rec {
56 name = "mantisbt-${version}";
57 version = "2.11.1";
58 src = fetchurl {
59 url = "https://downloads.sourceforge.net/project/mantisbt/mantis-stable/${version}/${name}.tar.gz";
60 sha256 = "0jnrqz6r2hf53v0k1lh3il7hlfiphn61r9wgg6mzyywkjxwq07md";
61 };
62 patches = [
63 ./patches/bug_report.php.diff
64 ./patches/bug_report_page.php.diff
65 ./patches/bugnote_add.php.diff
66 ./patches/bugnote_add_inc.php.diff
67 ];
68 installPhase = ''
69 cp -a . $out
70 ln -s ${config} $out/config/config_inc.php
71 ln -s ${plugins.slack} $out/plugins/Slack
72 ln -s ${plugins.source-integration}/Source* $out/plugins/
73 '';
74 };
75 apache = {
76 user = "wwwrun";
77 group = "wwwrun";
78 modules = [ "proxy_fcgi" ];
79 vhostConf = ''
80 Alias /mantisbt "${webRoot}"
81 <Directory "${webRoot}">
82 DirectoryIndex index.php
83 <FilesMatch "\.php$">
84 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
85 </FilesMatch>
86
87 AllowOverride All
88 Options FollowSymlinks
89 Require all granted
90 </Directory>
91 <Directory "${webRoot}/admin">
92 #Reenable during upgrade
93 Require all denied
94 </Directory>
95 '';
96 };
97 phpFpm = rec {
98 basedir = builtins.concatStringsSep ":" (
99 [ webRoot config ]
100 ++ lib.attrsets.mapAttrsToList (name: value: value) plugins);
101 socket = "/var/run/phpfpm/mantisbt.sock";
102 pool = ''
103 listen = ${socket}
104 user = ${apache.user}
105 group = ${apache.group}
106 listen.owner = ${apache.user}
107 listen.group = ${apache.group}
108 pm = ondemand
109 pm.max_children = 60
110 pm.process_idle_timeout = 60
111
112 php_admin_value[upload_max_filesize] = 5000000
113
114 php_admin_value[open_basedir] = "${basedir}:/tmp"
115 php_admin_value[session.save_path] = "/var/lib/php/sessions/mantisbt"
116 '';
117 };
118 };
119 in
120 mantisbt