]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - virtual/packages/mantisbt.nix
Move httpd service to module
[perso/Immae/Config/Nix.git] / virtual / packages / mantisbt.nix
CommitLineData
5c101474 1{ lib, checkEnv, writeText, stdenv, fetchurl, fetchedGithub }:
50d8fa14
IB
2let
3 # FIXME: check that source-integration and slack still work
4 mantisbt = let
5 plugins = {
6 slack = stdenv.mkDerivation (fetchedGithub ./mantisbt-plugin-slack.json // rec {
7 installPhase = ''
8 sed -i -e "s/return '@' . \\\$username;/return \\\$username;/" Slack.php
9 cp -a . $out
10 '';
11 });
12 source-integration = stdenv.mkDerivation (fetchedGithub ./mantisbt-plugin-source-integration.json // rec {
13 installPhase = ''
14 mkdir $out
15 patch -p1 < ${./mantisbt-plugin-source-integration_Source.API.php.diff}
16 cp -a Source* $out/
17 '';
18 });
19 };
20 in rec {
21 config =
22 assert checkEnv "NIXOPS_MANTISBT_DB_PASSWORD";
23 assert checkEnv "NIXOPS_MANTISBT_MASTER_SALT";
24 assert checkEnv "NIXOPS_MANTISBT_LDAP_PASSWORD";
5c101474 25 writeText "config_inc.php" ''
50d8fa14
IB
26 <?php
27 $g_hostname = 'db-1.immae.eu';
28 $g_db_username = 'mantisbt';
29 $g_db_password = '${builtins.getEnv "NIXOPS_MANTISBT_DB_PASSWORD"}';
30 $g_database_name = 'mantisbt';
31 $g_db_type = 'pgsql';
32 $g_crypto_master_salt = '${builtins.getEnv "NIXOPS_MANTISBT_MASTER_SALT"}';
33 $g_allow_signup = OFF;
34 $g_allow_anonymous_login = ON;
35 $g_anonymous_account = 'anonymous';
36
37 $g_phpMailer_method = PHPMAILER_METHOD_SMTP;
38 $g_smtp_host = 'mail.immae.eu';
39 $g_smtp_username = ''';
40 $g_smtp_password = ''';
41 $g_webmaster_email = 'webmaster@immae.eu';
42 $g_from_email = 'noreply@immae.eu';
43 $g_return_path_email = 'webmaster@immae.eu';
44 $g_from_name = 'Mantis Bug Tracker at 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 = '${builtins.getEnv "NIXOPS_MANTISBT_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)';
58 '';
59 webRoot = stdenv.mkDerivation rec {
60 name = "mantisbt-${version}";
61 version = "2.11.1";
62 src = fetchurl {
63 url = "https://downloads.sourceforge.net/project/mantisbt/mantis-stable/${version}/${name}.tar.gz";
64 sha256 = "0jnrqz6r2hf53v0k1lh3il7hlfiphn61r9wgg6mzyywkjxwq07md";
65 };
66 patches = [
67 ./mantisbt-patches/bug_report.php.diff
68 ./mantisbt-patches/bug_report_page.php.diff
69 ./mantisbt-patches/bugnote_add.php.diff
70 ./mantisbt-patches/bugnote_add_inc.php.diff
71 ];
72 installPhase = ''
73 cp -a . $out
74 ln -s ${config} $out/config/config_inc.php
75 ln -s ${plugins.slack} $out/plugins/Slack
76 ln -s ${plugins.source-integration}/Source* $out/plugins/
77 '';
78 };
79 apache = {
80 user = "wwwrun";
81 group = "wwwrun";
82 modules = [ "proxy_fcgi" ];
83 vhostConf = ''
84 Alias /mantisbt "${webRoot}"
85 <Directory "${webRoot}">
86 DirectoryIndex index.php
87 <FilesMatch "\.php$">
88 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
89 </FilesMatch>
90
91 AllowOverride All
92 Options FollowSymlinks
93 Require all granted
94 </Directory>
95 <Directory "${webRoot}/admin">
96 #Reenable during upgrade
97 Require all denied
98 </Directory>
99 '';
100 };
101 phpFpm = rec {
102 basedir = builtins.concatStringsSep ":" (
103 [ webRoot config ]
5c101474 104 ++ lib.attrsets.mapAttrsToList (name: value: value) plugins);
50d8fa14
IB
105 socket = "/var/run/phpfpm/mantisbt.sock";
106 pool = ''
107 listen = ${socket}
108 user = ${apache.user}
109 group = ${apache.group}
110 listen.owner = ${apache.user}
111 listen.group = ${apache.group}
112 pm = ondemand
113 pm.max_children = 60
114 pm.process_idle_timeout = 60
115
116 php_admin_value[upload_max_filesize] = 5000000
117
118 php_admin_value[open_basedir] = "${basedir}:/tmp"
c8e019b6 119 php_admin_value[session.save_path] = "/var/lib/php/sessions/mantisbt"
50d8fa14
IB
120 '';
121 };
122 };
123in
124 mantisbt