Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 15995ea2b29d
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 159a5f31bc85
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Nov 5, 2018

  1. 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.
    griff committed Nov 5, 2018

    Unverified

    No user is associated with the committer email.
    Copy the full SHA
    c853b34 View commit details

Commits on Nov 6, 2018

  1. Merge pull request #49792 from griff/rspamd-multifile-enable

    nixos/rspamd: Fix enable for locals and overrides
    fpletz authored Nov 6, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    159a5f3 View commit details
Showing with 34 additions and 12 deletions.
  1. +5 −4 nixos/modules/services/mail/rspamd.nix
  2. +29 −8 nixos/tests/rspamd.nix
9 changes: 5 additions & 4 deletions nixos/modules/services/mail/rspamd.nix
Original file line number Diff line number Diff line change
@@ -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>.
37 changes: 29 additions & 8 deletions nixos/tests/rspamd.nix
Original file line number Diff line number Diff line change
@@ -110,16 +110,33 @@ in
'';
services.rspamd = {
enable = true;
locals."groups.conf".text = ''
group "cows" {
symbol {
NO_MUH = {
weight = 1.0;
description = "Mails should not muh";
locals = {
"antivirus.conf" = mkIf false { text = ''
clamav {
action = "reject";
symbol = "CLAM_VIRUS";
type = "clamav";
log_clean = true;
servers = "/run/clamav/clamd.ctl";
}
'';};
"redis.conf" = {
enable = false;
text = ''
servers = "127.0.0.1";
'';
};
"groups.conf".text = ''
group "cows" {
symbol {
NO_MUH = {
weight = 1.0;
description = "Mails should not muh";
}
}
}
}
'';
'';
};
localLuaRules = pkgs.writeText "rspamd.local.lua" ''
local rspamd_logger = require "rspamd_logger"
rspamd_config.NO_MUH = {
@@ -152,6 +169,10 @@ in
$machine->log($machine->succeed("cat /etc/rspamd/rspamd.conf"));
$machine->log($machine->succeed("cat /etc/rspamd/rspamd.local.lua"));
$machine->log($machine->succeed("cat /etc/rspamd/local.d/groups.conf"));
# Verify that redis.conf was not written
$machine->fail("cat /etc/rspamd/local.d/redis.conf >&2");
# Verify that antivirus.conf was not written
$machine->fail("cat /etc/rspamd/local.d/antivirus.conf >&2");
${checkSocket "/run/rspamd/rspamd.sock" "rspamd" "rspamd" "660" }
$machine->log($machine->succeed("curl --unix-socket /run/rspamd/rspamd.sock http://localhost/ping"));
$machine->log($machine->succeed("rspamc -h 127.0.0.1:11334 stat"));