From 0d753af6617bb74535af0601a2cdce1a8c647889 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sun, 25 Nov 2018 06:10:30 +0100 Subject: [PATCH] nixos/rspamd: Allow worker type to be proxy again When reworking the rspamd workers I disallowed `proxy` as a type and instead used `rspamd_proxy` which is the correct name for that worker type. That change breaks peoples existing config and so I have made this commit which allows `proxy` as a worker type again but makes it behave as `rspamd_proxy` and prints a warning if you use it. --- nixos/modules/services/mail/rspamd.nix | 17 ++++++++++++++--- nixos/tests/rspamd.nix | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/mail/rspamd.nix b/nixos/modules/services/mail/rspamd.nix index 1c37ae41e07dd3..c9ba867802130a 100644 --- a/nixos/modules/services/mail/rspamd.nix +++ b/nixos/modules/services/mail/rspamd.nix @@ -45,7 +45,9 @@ let else "${config.socket}${maybeOption "mode"}${maybeOption "owner"}${maybeOption "group"}"; }; - workerOpts = { name, ... }: { + traceWarning = w: x: builtins.trace "warning: ${w}" x; + + workerOpts = { name, options, ... }: { options = { enable = mkOption { type = types.nullOr types.bool; @@ -59,9 +61,18 @@ let }; type = mkOption { type = types.nullOr (types.enum [ - "normal" "controller" "fuzzy_storage" "rspamd_proxy" "lua" + "normal" "controller" "fuzzy_storage" "rspamd_proxy" "lua" "proxy" ]); - description = "The type of this worker"; + description = '' + The type of this worker. The type proxy is + deprecated and only kept for backwards compatibility and should be + replaced with rspamd_proxy. + ''; + apply = let + from = "services.rspamd.workers.\”${name}\".type"; + files = options.type.files; + warning = "The option `${from}` defined in ${showFiles files} has enum value `proxy` which has been renamed to `rspamd_proxy`"; + in x: if x == "proxy" then traceWarning warning "rspamd_proxy" else x; }; bindSockets = mkOption { type = types.listOf (types.either types.str (types.submodule bindSocketOpts)); diff --git a/nixos/tests/rspamd.nix b/nixos/tests/rspamd.nix index e16a9e6ffbc600..396cd5b67d81b9 100644 --- a/nixos/tests/rspamd.nix +++ b/nixos/tests/rspamd.nix @@ -235,6 +235,7 @@ in services.rspamd = { enable = true; postfix.enable = true; + workers.rspamd_proxy.type = "proxy"; }; }; testScript = ''