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