Refactor parsers in crowdsec module to make use of symlinkjoin

Fixes failing build when running nix flake check --no-build because
store paths may not be present.
This commit is contained in:
Louis Roebben
2024-09-27 23:10:15 +02:00
committed by Florian Brandes
parent 0d17910a6b
commit 979ba367b3
2 changed files with 13 additions and 14 deletions

View File

@@ -10,17 +10,9 @@
pkg = cfg.package;
defaultPatterns = lib.mapAttrs (name: value: lib.mkDefault "${pkg}/share/crowdsec/config/patterns/${name}") (builtins.readDir "${pkg}/share/crowdsec/config/patterns");
defaultPatterns = [pkg.patterns];
patternsDir = pkgs.runCommandNoCC "crowdsec-patterns" {} ''
mkdir -p $out
${lib.concatStringsSep "\n" (lib.attrValues (lib.mapAttrs (
k: v: ''
ln -sf ${v} $out/${k}
''
)
cfg.patterns))}
'';
patternsDir = pkgs.symlinkJoin { name = "crowdsec-merged-patterns"; paths = [cfg.patterns];};
defaultSettings = with lib; {
common = {
@@ -118,14 +110,15 @@ in {
};
patterns = mkOption {
description = mdDoc ''
A set of pattern files for parsing logs, in the form "type" to file containing the corresponding GROK patterns.
A list of pattern derrivations for parsing logs, in the form "type" to file containing the corresponding GROK patterns.
Files in the derriviatons will be merged into one and must only contains files in the root of the derivation.
All default patterns are automatically included.
See <https://github.com/crowdsecurity/crowdsec/tree/master/config/patterns>.
'';
type = types.attrsOf types.pathInStore;
default = {};
type = types.listOf types.package; #types.attrsOf types.pathInStore;
default = [];
example = lib.literalExpression ''
{ ssh = ./patterns/ssh;}
[ (pkgs.writeTextDir "ssh" (builtins.readFile ./ssh)) ]
'';
};
settings = mkOption {