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