]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - virtual/modules/websites/tools/tools/roundcubemail.nix
Fix deprecation for networking addresses in hetzner
[perso/Immae/Config/Nix.git] / virtual / modules / websites / tools / tools / roundcubemail.nix
CommitLineData
d252d718
IB
1{ lib, checkEnv, writeText, stdenv, fetchurl }:
2let
3 roundcubemail = let
4 plugins = {};
5 in rec {
6 varDir = "/var/lib/roundcubemail";
d252d718
IB
7 activationScript = {
8 deps = [ "wrappers" ];
9 text = ''
10 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
11 ${varDir}/cache
12 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
13 '';
14 };
15 config =
d252d718
IB
16 assert checkEnv "NIXOPS_ROUNDCUBEMAIL_PSQL_URL";
17 assert checkEnv "NIXOPS_ROUNDCUBEMAIL_SECRET";
18 writeText "config.php" ''
19 <?php
20 $config['db_dsnw'] = '${builtins.getEnv "NIXOPS_ROUNDCUBEMAIL_PSQL_URL"}';
21 $config['default_host'] = 'ssl://mail.immae.eu';
22 $config['imap_conn_options'] = array("ssl" => array("verify_peer" => false));
23 $config['smtp_server'] = 'tls://mail.immae.eu';
24
25 $config['imap_cache'] = 'db';
26 $config['messages_cache'] = 'db';
27
28 $config['support_url'] = ''';
29
30 $config['des_key'] = '${builtins.getEnv "NIXOPS_ROUNDCUBEMAIL_SECRET"}';
31
32 $config['plugins'] = array();
33
34 $config['language'] = 'fr_FR';
35
36 $config['drafts_mbox'] = 'Mail/Drafts';
37 $config['junk_mbox'] = 'Mail/Spam';
38 $config['sent_mbox'] = 'Mail/sent';
39 $config['trash_mbox'] = ''';
40 $config['default_folders'] = array('INBOX', 'Mail/Drafts', 'Mail/sent', 'Mail/Spam', ''');
41 $config['draft_autosave'] = 60;
42 $config['enable_installer'] = false;
43 $config['log_driver'] = 'stdout';
44 $config['temp_dir'] = '${varDir}/cache';
45 $config['debug_level'] = 1;
46 '';
47 webRoot = stdenv.mkDerivation rec {
48 version = "1.3.8";
49 name = "roundcubemail-${version}";
50 src= fetchurl {
51 url = "https://github.com/roundcube/roundcubemail/releases/download/${version}/${name}-complete.tar.gz";
52 sha256 = "018djad7ygfl9c9f2l2j42qkg31ml3hs2f01f0dk361zckwk77n4";
53 };
54 buildPhase = ''
55 sed -i \
56 -e "s|RCUBE_INSTALL_PATH . 'temp.*|'${varDir}/cache';|" \
57 config/defaults.inc.php
58 '';
59 installPhase = ''
60 cp -a . $out
61 ln -s ${config} $out/config/config.inc.php
62 ${builtins.concatStringsSep "\n" (
63 lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/plugins/${name}") plugins
64 )}
65 '';
66 };
67 apache = {
68 user = "wwwrun";
69 group = "wwwrun";
70 modules = [ "proxy_fcgi" ];
71 vhostConf = ''
72 Alias /roundcube "${webRoot}"
73 <Directory "${webRoot}">
74 DirectoryIndex index.php
75 AllowOverride All
76 Options FollowSymlinks
77 Require all granted
78
79 <FilesMatch "\.php$">
80 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
81 </FilesMatch>
82 </Directory>
83 '';
84 };
85 phpFpm = rec {
86 basedir = builtins.concatStringsSep ":" (
87 [ webRoot config varDir ]
88 ++ lib.attrsets.mapAttrsToList (name: value: value) plugins);
89 socket = "/var/run/phpfpm/roundcubemail.sock";
90 pool = ''
91 listen = ${socket}
92 user = ${apache.user}
93 group = ${apache.group}
94 listen.owner = ${apache.user}
95 listen.group = ${apache.group}
96 pm = ondemand
97 pm.max_children = 60
98 pm.process_idle_timeout = 60
99
100 ; Needed to avoid clashes in browser cookies (same domain)
101 php_value[session.name] = RoundcubemailPHPSESSID
102 php_admin_value[open_basedir] = "${basedir}:/tmp"
103 php_admin_value[session.save_path] = "${varDir}/phpSessions"
104 '';
105 };
106 };
107in
108 roundcubemail