summary refs log tree commit diff
path: root/nixos/modules/services/mail/roundcube.nix
diff options
context:
space:
mode:
authorVictor SENE <victor@sene.ovh>2018-10-01 17:12:56 +0200
committerRobin Gloster <mail@glob.in>2018-11-28 18:52:08 +0100
commitb5120953c6f27e5bab6a4a02744c0bae47f80a3c (patch)
treeaabe56d8293e139883d015189f542afb515e6039 /nixos/modules/services/mail/roundcube.nix
parent24865963f0e7886e1a42d8aa112306d7cc6cfbd8 (diff)
downloadnixpkgs-b5120953c6f27e5bab6a4a02744c0bae47f80a3c.tar
nixpkgs-b5120953c6f27e5bab6a4a02744c0bae47f80a3c.tar.gz
nixpkgs-b5120953c6f27e5bab6a4a02744c0bae47f80a3c.tar.bz2
nixpkgs-b5120953c6f27e5bab6a4a02744c0bae47f80a3c.tar.lz
nixpkgs-b5120953c6f27e5bab6a4a02744c0bae47f80a3c.tar.xz
nixpkgs-b5120953c6f27e5bab6a4a02744c0bae47f80a3c.tar.zst
nixpkgs-b5120953c6f27e5bab6a4a02744c0bae47f80a3c.zip
nixos/roundcube: add roundcube module and default configuration
Diffstat (limited to 'nixos/modules/services/mail/roundcube.nix')
-rw-r--r--nixos/modules/services/mail/roundcube.nix89
1 files changed, 89 insertions, 0 deletions
diff --git a/nixos/modules/services/mail/roundcube.nix b/nixos/modules/services/mail/roundcube.nix
new file mode 100644
index 00000000000..fc655add00e
--- /dev/null
+++ b/nixos/modules/services/mail/roundcube.nix
@@ -0,0 +1,89 @@
+{ lib, config, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.roundcube;
+in
+{
+  options.services.roundcube = {
+    enable = mkEnableOption "Roundcube";
+
+    listenAddress = mkOption {
+      type = types.str;
+      default = 127.0.0.1;
+      description = "Listening address";
+    };
+
+    listenPort = mkOption {
+      type = types.int;
+      default = 80;
+      description = "Listening port";
+    };
+    
+    subDomain = mkOption {
+      type = types.str;
+      example = "webmail";
+      description = "Sub-domain to use which is the name of the nginx vhost";
+    };
+    
+    extraConfig = mkOption {
+      type = types.str;
+      default = ''
+        <?php
+
+        $config = array();
+        $config['db_dsnw'] = 'pgsql://roundcube:pass@localhost/roundcubemail';
+        $config['db_prefix'] = 'rc';
+        $config['default_host'] = 'tls://%h';
+        $config['smtp_server'] = 'tls://%h';
+        $config['smtp_user'] = '%u';
+        $config['smtp_pass'] = '%p';
+
+        $config['max_message_size'] = '25M';
+      '';
+      description = "Configuration for roundcube webmail instance";
+    };
+  };
+
+  config = mkIf cfg.enable {
+    environment.etc."roundcube/config.inc.php".text = cfg.extraConfig;
+
+    services.nginx.virtualHosts = {
+      "${cfg.subDomain}" = {
+        listen = [ { addr = cfg.listenAddress; port = cfg.listenPort; } ];
+        locations."/" = {
+          root = pkgs.roundcube;
+          index = "index.php";
+          extraConfig = ''
+            location ~* \.php$ {
+              fastcgi_split_path_info ^(.+\.php)(/.+)$;
+              fastcgi_pass unix:/run/phpfpm/roundcube;
+              include ${pkgs.nginx}/conf/fastcgi_params;
+              include ${pkgs.nginx}/conf/fastcgi.conf;
+            }
+          '';
+        };
+      };
+    };
+
+    services.phpfpm.poolConfigs.${cfg.subDomain} = ''
+      listen = /run/phpfpm/roundcube
+      listen.owner = nginx
+      listen.group = nginx
+      listen.mode = 0660
+      user = nginx
+      pm = dynamic
+      pm.max_children = 75
+      pm.start_servers = 2
+      pm.min_spare_servers = 1
+      pm.max_spare_servers = 20
+      pm.max_requests = 500
+      php_admin_value[error_log] = 'stderr'
+      php_admin_flag[log_errors] = on
+      php_admin_value[post_max_size] = 25M
+      php_admin_value[upload_max_filesize] = 25M
+      catch_workers_output = yes
+   '';
+  };
+}