Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/roundcube: add roundcube module #47655

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Expand Up @@ -324,6 +324,7 @@
./services/mail/spamassassin.nix
./services/mail/rspamd.nix
./services/mail/rmilter.nix
./services/mail/roundcube.nix
./services/mail/nullmailer.nix
./services/misc/airsonic.nix
./services/misc/apache-kafka.nix
Expand Down
89 changes: 89 additions & 0 deletions 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 = "[::]";
description = "Listening address. IPv6 addresses must be enclosed in square brackets";
};

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;
Vskilet marked this conversation as resolved.
Show resolved Hide resolved
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
'';
};
}