1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
{ lib, env, writeText, stdenv, fetchurl, fetchedGithub, phpPackages, apacheHttpd }:
let
roundcubemail = let
defaultInstall = ''
mkdir -p $out
cp -R . $out/
cd $out
if [ -d skins -a -d skins/larry -a ! -d skins/elastic ]; then
ln -s larry skins/elastic
fi
'';
buildPlugin = { appName, version, url, sha256, installPhase ? defaultInstall }:
stdenv.mkDerivation rec {
name = "roundcube-${appName}-${version}";
inherit version;
phases = "unpackPhase installPhase";
inherit installPhase;
src = fetchurl { inherit url sha256; };
};
plugins = {
carddav = buildPlugin rec {
appName = "carddav";
version = "3.0.3";
url = "https://github.com/blind-coder/rcmcarddav/releases/download/v${version}/${appName}-${version}.tar.bz2";
sha256 = "0cf5rnqkhhag2vdy808zfpr4l5586fn43nvcia8ac1ha58azrxal";
};
contextmenu = buildPlugin rec {
appName = "contextmenu";
version = "2.3";
url = "https://github.com/johndoh/roundcube-${appName}/archive/${version}.tar.gz";
sha256 = "1rb8n821ylfniiiccfskc534vd6rczhk3g82455ks3m09q6l8hif";
};
contextmenu_folder = buildPlugin rec {
appName = "contextmenu_folder";
version = "1.3.3";
url = "https://github.com/random-cuber/${appName}/archive/${version}.tar.gz";
sha256 = "1ngfws1v8qrpa52rjh7kirc98alchk2vbqwra86h00agyjjlcc57";
};
automatic_addressbook = buildPlugin rec {
appName = "automatic_addressbook";
version = "0.4.3";
url = "https://github.com/sblaisot/${appName}/archive/${version}.tar.gz";
sha256 = "0bx5qjzp3a3wc72fr295bvgsy5n15949c041hq76n6c7sqdn7inc";
};
message_highlight = buildPlugin rec {
appName = "message_highlight";
version = "4.4";
url = "https://github.com/corbosman/${appName}/archive/${version}.tar.gz";
sha256 = "12c4x47y70xdl5pgm8csh5i4yiyhpi232lvjbixmca6di4lkhh9j";
};
thunderbird_labels = buildPlugin rec {
appName = "thunderbird_labels";
version = "v1.3.2";
url = "https://github.com/mike-kfed/roundcube-${appName}/archive/${version}.tar.gz";
sha256 = "1q4x30w66m02v3lw2n8020g0158rmyfzs6gydfk89pa1hs28k9bg";
};
html5_notifier = buildPlugin rec {
appName = "html5_notifier";
version = "v0.6.2";
url = "https://github.com/stremlau/${appName}/archive/${version}.tar.gz";
sha256 = "0s1wq9ira4bcd8jvhn93nhxiqzpp92i0za2kw37kf7ksyhr0xslq";
};
ident_switch = buildPlugin rec {
appName = "ident_switch";
version = "4.0.1";
url = "https://bitbucket.org/BoresExpress/${appName}/get/${version}.tar.gz";
sha256 = "1zyy40lfq2kn7hkghbl8lgp18fb634zr4fxmmxvb1wqyvqdpdpyk";
};
};
skins = {};
in rec {
varDir = "/var/lib/roundcubemail";
activationScript = {
deps = [ "wrappers" ];
text = ''
install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
${varDir}/cache ${varDir}/logs
install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
'';
};
config = writeText "config.php" ''
<?php
$config['db_dsnw'] = '${env.psql_url}';
$config['default_host'] = 'ssl://mail.immae.eu';
$config['imap_conn_options'] = array("ssl" => array("verify_peer" => false));
$config['smtp_server'] = 'tls://mail.immae.eu';
$config['imap_cache'] = 'db';
$config['messages_cache'] = 'db';
$config['support_url'] = ''';
$config['des_key'] = '${env.secret}';
$config['skin'] = 'elastic';
$config['plugins'] = array(
// 'acl',
// 'additional_message_headers',
// 'archive',
'attachment_reminder',
// 'autologon',
// 'database_attachments',
// 'debug_logger',
// 'emoticons',
// 'enigma',
// 'example_addressbook',
// 'filesystem_attachments',
// 'help',
// 'hide_blockquote',
// 'http_authentication',
// 'identicon',
// 'identity_select',
// 'jqueryui',
// 'krb_authentication',
// 'managesieve',
// 'markasjunk',
// 'new_user_dialog',
// 'new_user_identity',
// 'newmail_notifier',
// 'password',
// 'redundant_attachments',
// 'show_additional_headers',
// 'squirrelmail_usercopy',
// 'subscriptions_option',
// 'userinfo',
// 'vcard_attachments',
// 'virtuser_file',
// 'virtuser_query',
// 'zipdownload',
// 'automatic_addressbook',
// 'carddav',
// 'contextmenu',
// 'contextmenu_folder',
// 'html5_notifier',
// 'ident_switch',
// 'message_highlight',
// 'thunderbird_labels',
);
$config['language'] = 'fr_FR';
$config['drafts_mbox'] = 'Mail/Drafts';
$config['junk_mbox'] = 'Mail/Spam';
$config['sent_mbox'] = 'Mail/sent';
$config['trash_mbox'] = ''';
$config['default_folders'] = array('INBOX', 'Mail/Drafts', 'Mail/sent', 'Mail/Spam', ''');
$config['draft_autosave'] = 60;
$config['enable_installer'] = false;
$config['log_driver'] = 'stdout';
$config['temp_dir'] = '${varDir}/cache';
$config['mime_types'] = '${apacheHttpd}/conf/mime.types';
'';
webRoot = stdenv.mkDerivation rec {
version = "1.4-rc1";
name = "roundcubemail-${version}";
src= fetchurl {
url = "https://github.com/roundcube/roundcubemail/releases/download/${version}/${name}-complete.tar.gz";
sha256 = "0p18wffwi2prh6vxhx1bc69qd1vwybggm8gvg3shahfdknxci9i4";
};
buildPhase = ''
sed -i \
-e "s|RCUBE_INSTALL_PATH . 'temp.*|'${varDir}/cache';|" \
config/defaults.inc.php
sed -i \
-e "s|RCUBE_INSTALL_PATH . 'logs.*|'${varDir}/logs';|" \
config/defaults.inc.php
'';
installPhase = ''
cp -a . $out
ln -s ${config} $out/config/config.inc.php
${builtins.concatStringsSep "\n" (
lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/plugins/${name}") plugins
)}
${builtins.concatStringsSep "\n" (
lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/skins/${name}") skins
)}
'';
};
apache = rec {
user = "wwwrun";
group = "wwwrun";
modules = [ "proxy_fcgi" ];
webappName = "tools_roundcubemail";
root = "/run/current-system/webapps/${webappName}";
vhostConf = ''
Alias /roundcube "${root}"
<Directory "${root}">
DirectoryIndex index.php
AllowOverride All
Options FollowSymlinks
Require all granted
<FilesMatch "\.php$">
SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
</FilesMatch>
</Directory>
'';
};
phpFpm = rec {
basedir = builtins.concatStringsSep ":" (
[ webRoot config varDir ]
++ lib.attrsets.mapAttrsToList (name: value: value) plugins
++ lib.attrsets.mapAttrsToList (name: value: value) skins);
phpConfig = ''
date.timezone = 'CET'
extension=${phpPackages.imagick}/lib/php/extensions/imagick.so
'';
socket = "/var/run/phpfpm/roundcubemail.sock";
pool = ''
listen = ${socket}
user = ${apache.user}
group = ${apache.group}
listen.owner = ${apache.user}
listen.group = ${apache.group}
pm = ondemand
pm.max_children = 60
pm.process_idle_timeout = 60
; Needed to avoid clashes in browser cookies (same domain)
php_value[session.name] = RoundcubemailPHPSESSID
php_admin_value[upload_max_filesize] = 200M
php_admin_value[post_max_size] = 200M
php_admin_value[open_basedir] = "${basedir}:${apacheHttpd}/conf/mime.types:/tmp"
php_admin_value[session.save_path] = "${varDir}/phpSessions"
'';
};
};
in
roundcubemail
|