From d252d718e9d42fb3a13d64e5b8daa37ca9264211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Tue, 8 Jan 2019 13:28:22 +0100 Subject: Add roundcubemail --- virtual/packages/roundcubemail.nix | 110 +++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 virtual/packages/roundcubemail.nix (limited to 'virtual/packages/roundcubemail.nix') diff --git a/virtual/packages/roundcubemail.nix b/virtual/packages/roundcubemail.nix new file mode 100644 index 0000000..1aa2d87 --- /dev/null +++ b/virtual/packages/roundcubemail.nix @@ -0,0 +1,110 @@ +{ lib, checkEnv, writeText, stdenv, fetchurl }: +let + roundcubemail = let + plugins = {}; + in rec { + varDir = "/var/lib/roundcubemail"; + # FIXME: initial sync + activationScript = { + deps = [ "wrappers" ]; + text = '' + install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ + ${varDir}/cache + install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions + ''; + }; + config = + # FIXME: LOG_DESTINATION syslog? + assert checkEnv "NIXOPS_ROUNDCUBEMAIL_PSQL_URL"; + assert checkEnv "NIXOPS_ROUNDCUBEMAIL_SECRET"; + writeText "config.php" '' + 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'] = '${builtins.getEnv "NIXOPS_ROUNDCUBEMAIL_SECRET"}'; + + $config['plugins'] = array(); + + $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['debug_level'] = 1; + ''; + webRoot = stdenv.mkDerivation rec { + version = "1.3.8"; + name = "roundcubemail-${version}"; + src= fetchurl { + url = "https://github.com/roundcube/roundcubemail/releases/download/${version}/${name}-complete.tar.gz"; + sha256 = "018djad7ygfl9c9f2l2j42qkg31ml3hs2f01f0dk361zckwk77n4"; + }; + buildPhase = '' + sed -i \ + -e "s|RCUBE_INSTALL_PATH . 'temp.*|'${varDir}/cache';|" \ + 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 + )} + ''; + }; + apache = { + user = "wwwrun"; + group = "wwwrun"; + modules = [ "proxy_fcgi" ]; + vhostConf = '' + Alias /roundcube "${webRoot}" + + DirectoryIndex index.php + AllowOverride All + Options FollowSymlinks + Require all granted + + + SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" + + + ''; + }; + phpFpm = rec { + basedir = builtins.concatStringsSep ":" ( + [ webRoot config varDir ] + ++ lib.attrsets.mapAttrsToList (name: value: value) plugins); + 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[open_basedir] = "${basedir}:/tmp" + php_admin_value[session.save_path] = "${varDir}/phpSessions" + ''; + }; + }; +in + roundcubemail -- cgit v1.2.3