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