summaryrefslogtreecommitdiffstats
path: root/default.nix
diff options
context:
space:
mode:
authorSymphorien Gibol <symphorien+git@xlumurb.eu>2020-04-03 12:00:00 +0000
committerlewo <lewo@abesis.fr>2020-05-05 19:07:46 +0000
commit9e772d166cb5b9654899e3d70d3006a494fb09b0 (patch)
treef4941fda7e37ca6a9f98b22f3bcaf6c5692dca69 /default.nix
parentac0f5c118f9a92edf30e8a1d899e17f78a8c1858 (diff)
rspamd: configure redis backend
The sqlite backed is deprecated, and the redis backend is the default since rspamd 2.0. Not having redis started results in such errors: rspamd_redis_init: cannot init redis backend for BAYES_SPAM To migrate the sqlite database, run rspamadm statconvert --spam-db /var/lib/rspamd/bayes.spam.sqlite --ham-db /var/lib/rspamd/bayes.ham.sqlite -h 127.0.0.1:6379 --symbol-ham BAYES_HAM --symbol-spam BAYES_SPAM The current module implements the recommended configuration that this utility prints out.
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index e6aaf8c..86cbe19 100644
--- a/default.nix
+++ b/default.nix
@@ -480,6 +480,46 @@ in
'';
};
+ redis = {
+ address = mkOption {
+ type = types.str;
+ # read the default from nixos' redis module
+ default = let
+ cf = config.services.redis.bind;
+ cfdefault = if cf == null then "127.0.0.1" else cf;
+ ips = lib.strings.splitString " " cfdefault;
+ ip = lib.lists.head (ips ++ [ "127.0.0.1" ]);
+ isIpv6 = ip: lib.lists.elem ":" (lib.stringToCharacters ip);
+ in
+ if (ip == "0.0.0.0" || ip == "::")
+ then "127.0.0.1"
+ else if isIpv6 ip then "[${ip}]" else ip;
+ description = ''
+ Address that rspamd should use to contact redis. The default value
+ is read from <literal>config.services.redis.bind</literal>.
+ '';
+ };
+
+ port = mkOption {
+ type = types.port;
+ default = config.services.redis.port;
+ description = ''
+ Port that rspamd should use to contact redis. The default value is
+ read from <literal>config.services.redis.port<literal>.
+ '';
+ };
+
+ password = mkOption {
+ type = types.nullOr types.str;
+ default = config.services.redis.requirePass;
+ description = ''
+ Password that rspamd should use to contact redis, or null if not
+ required. The default value is read from
+ <literal>config.services.redis.requirePass<literal>.
+ '';
+ };
+ };
+
rewriteMessageId = mkOption {
type = types.bool;
default = false;