Skip to content

Commit

Permalink
Merge pull request #84940 from symphorien/rouncube-spell
Browse files Browse the repository at this point in the history
roundcube: use pspell for spellchecking
  • Loading branch information
Ma27 committed Apr 11, 2020
2 parents 43020a8 + 9e417bc commit c9504b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion nixos/modules/services/mail/roundcube.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let
fpm = config.services.phpfpm.pools.roundcube;
localDB = cfg.database.host == "localhost";
user = cfg.database.username;
phpWithPspell = pkgs.php.withExtensions (e: [ e.pspell ] ++ pkgs.php.enabledExtensions);
in
{
options.services.roundcube = {
Expand Down Expand Up @@ -85,6 +86,15 @@ in
'';
};

dicts = mkOption {
type = types.listOf types.package;
default = [];
example = literalExample "with pkgs.aspellDicts; [ en fr de ]";
description = ''
List of aspell dictionnaries for spell checking. If empty, spell checking is disabled.
'';
};

extraConfig = mkOption {
type = types.lines;
default = "";
Expand All @@ -109,6 +119,11 @@ in
$config['plugins'] = [${concatMapStringsSep "," (p: "'${p}'") cfg.plugins}];
$config['des_key'] = file_get_contents('/var/lib/roundcube/des_key');
$config['mime_types'] = '${pkgs.nginx}/conf/mime.types';
$config['enable_spellcheck'] = ${if cfg.dicts == [] then "false" else "true"};
# by default, spellchecking uses a third-party cloud services
$config['spellcheck_engine'] = 'pspell';
$config['spellcheck_languages'] = array(${lib.concatMapStringsSep ", " (dict: let p = builtins.parseDrvName dict.shortName; in "'${p.name}' => '${dict.fullName}'") cfg.dicts});
${cfg.extraConfig}
'';

Expand Down Expand Up @@ -172,6 +187,8 @@ in
"pm.max_requests" = 500;
"catch_workers_output" = true;
};
phpPackage = phpWithPspell;
phpEnv.ASPELL_CONF = "dict-dir ${pkgs.aspellWithDicts (_: cfg.dicts)}/lib/aspell";
};
systemd.services.phpfpm-roundcube.after = [ "roundcube-setup.service" ];

Expand Down Expand Up @@ -199,7 +216,7 @@ in
${psql} <<< 'TRUNCATE TABLE session;'
fi
${pkgs.php}/bin/php ${cfg.package}/bin/update.sh
${phpWithPspell}/bin/php ${cfg.package}/bin/update.sh
'';
serviceConfig = {
Type = "oneshot";
Expand Down
1 change: 1 addition & 0 deletions nixos/tests/roundcube.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
database.password = "not production";
package = pkgs.roundcube.withPlugins (plugins: [ plugins.persistent_login ]);
plugins = [ "persistent_login" ];
dicts = with pkgs.aspellDicts; [ en fr de ];
};
services.nginx.virtualHosts.roundcube = {
forceSSL = false;
Expand Down

0 comments on commit c9504b0

Please sign in to comment.