From 745c6ee86199123b12f3c028c44bf41813f8c102 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 13 Apr 2025 03:54:51 +0200 Subject: [PATCH] rspamd: Use redis over a unix socket by default Both rspamd and redis run on the same host by default, so a UNIX domain socket is the cheapest way to facilitate that communication. It also allows us to get rid of overly complicated IP adddress parsing logic, that we can shift onto the user if they need it. --- default.nix | 23 +++++++---------------- docs/release-notes.rst | 8 ++++++++ mail-server/rspamd.nix | 12 +++++++----- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/default.nix b/default.nix index 4008df3..17fd16d 100644 --- a/default.nix +++ b/default.nix @@ -944,28 +944,19 @@ in address = mkOption { type = types.str; # read the default from nixos' redis module - default = let - cf = config.services.redis.servers.rspamd.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; - defaultText = lib.literalMD "computed from `config.services.redis.servers.rspamd.bind`"; + default = config.services.redis.servers.rspamd.unixSocket; + defaultText = lib.literalExpression "config.services.redis.servers.rspamd.unixSocket"; description = '' - Address that rspamd should use to contact redis. + Path, IP address or hostname that Rspamd should use to contact Redis. ''; }; port = mkOption { - type = types.port; - default = config.services.redis.servers.rspamd.port; - defaultText = lib.literalExpression "config.services.redis.servers.rspamd.port"; + type = with types; nullOr port; + default = null; + example = lib.literalExpression "config.services.redis.servers.rspamd.port"; description = '' - Port that rspamd should use to contact redis. + Port that Rspamd should use to contact Redis. ''; }; diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 806de8e..0cade83 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -1,6 +1,14 @@ Release Notes ============= +NixOS 25.05 +----------- + +- Rspamd now connects to Redis over its Unix Domain Socket by default + (`merge request