summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorBrian Olsen <brian@maven-group.org>2018-11-05 17:50:34 +0100
committerBrian Olsen <brian@maven-group.org>2018-11-05 17:50:34 +0100
commitc853b3482455fccd949b5fd0bc16b44f8bc72f23 (patch)
tree89c6c8e72089749abba2b696bc4bbac4f1b5a1a3 /nixos/modules
parent5c63ee6216a78d8d99300cdc52adb2207337780f (diff)
downloadnixlib-c853b3482455fccd949b5fd0bc16b44f8bc72f23.tar
nixlib-c853b3482455fccd949b5fd0bc16b44f8bc72f23.tar.gz
nixlib-c853b3482455fccd949b5fd0bc16b44f8bc72f23.tar.bz2
nixlib-c853b3482455fccd949b5fd0bc16b44f8bc72f23.tar.lz
nixlib-c853b3482455fccd949b5fd0bc16b44f8bc72f23.tar.xz
nixlib-c853b3482455fccd949b5fd0bc16b44f8bc72f23.tar.zst
nixlib-c853b3482455fccd949b5fd0bc16b44f8bc72f23.zip
nixos/rspamd: Fix enable for locals and overrides
When implementing #49620 I included an enable option for both the
locals and overrides options but the code writing the files didn't
actually look at enable and so would write the file regardless of its
value. I also set the type to loaOf which should have been attrsOf
since the code was not written to handle the options being lists.

This fixes both of those issues.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/mail/rspamd.nix9
1 files changed, 5 insertions, 4 deletions
diff --git a/nixos/modules/services/mail/rspamd.nix b/nixos/modules/services/mail/rspamd.nix
index d83d6f1f750c..78a2f37b6ded 100644
--- a/nixos/modules/services/mail/rspamd.nix
+++ b/nixos/modules/services/mail/rspamd.nix
@@ -153,9 +153,10 @@ let
       ${cfg.extraConfig}
    '';
 
+  filterFiles = files: filterAttrs (n: v: v.enable) files;
   rspamdDir = pkgs.linkFarm "etc-rspamd-dir" (
-    (mapAttrsToList (name: file: { name = "local.d/${name}"; path = file.source; }) cfg.locals) ++
-    (mapAttrsToList (name: file: { name = "override.d/${name}"; path = file.source; }) cfg.overrides) ++
+    (mapAttrsToList (name: file: { name = "local.d/${name}"; path = file.source; }) (filterFiles cfg.locals)) ++
+    (mapAttrsToList (name: file: { name = "override.d/${name}"; path = file.source; }) (filterFiles cfg.overrides)) ++
     (optional (cfg.localLuaRules != null) { name = "rspamd.local.lua"; path = cfg.localLuaRules; }) ++
     [ { name = "rspamd.conf"; path = rspamdConfFile; } ]
   );
@@ -207,7 +208,7 @@ in
       };
 
       locals = mkOption {
-        type = with types; loaOf (submodule (configFileModule "locals"));
+        type = with types; attrsOf (submodule (configFileModule "locals"));
         default = {};
         description = ''
           Local configuration files, written into <filename>/etc/rspamd/local.d/{name}</filename>.
@@ -220,7 +221,7 @@ in
       };
 
       overrides = mkOption {
-        type = with types; loaOf (submodule (configFileModule "overrides"));
+        type = with types; attrsOf (submodule (configFileModule "overrides"));
         default = {};
         description = ''
           Overridden configuration files, written into <filename>/etc/rspamd/override.d/{name}</filename>.