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:
@@ -10,17 +10,9 @@
|
|||||||
|
|
||||||
pkg = cfg.package;
|
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" {} ''
|
patternsDir = pkgs.symlinkJoin { name = "crowdsec-merged-patterns"; paths = [cfg.patterns];};
|
||||||
mkdir -p $out
|
|
||||||
${lib.concatStringsSep "\n" (lib.attrValues (lib.mapAttrs (
|
|
||||||
k: v: ''
|
|
||||||
ln -sf ${v} $out/${k}
|
|
||||||
''
|
|
||||||
)
|
|
||||||
cfg.patterns))}
|
|
||||||
'';
|
|
||||||
|
|
||||||
defaultSettings = with lib; {
|
defaultSettings = with lib; {
|
||||||
common = {
|
common = {
|
||||||
@@ -118,14 +110,15 @@ in {
|
|||||||
};
|
};
|
||||||
patterns = mkOption {
|
patterns = mkOption {
|
||||||
description = mdDoc ''
|
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.
|
All default patterns are automatically included.
|
||||||
See <https://github.com/crowdsecurity/crowdsec/tree/master/config/patterns>.
|
See <https://github.com/crowdsecurity/crowdsec/tree/master/config/patterns>.
|
||||||
'';
|
'';
|
||||||
type = types.attrsOf types.pathInStore;
|
type = types.listOf types.package; #types.attrsOf types.pathInStore;
|
||||||
default = {};
|
default = [];
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
{ ssh = ./patterns/ssh;}
|
[ (pkgs.writeTextDir "ssh" (builtins.readFile ./ssh)) ]
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ buildGoModule rec {
|
|||||||
|
|
||||||
vendorHash = "sha256-fl5LkRz69QOq4aPyAhMFxw1FWozLzofDBUGvRptuyZY=";
|
vendorHash = "sha256-fl5LkRz69QOq4aPyAhMFxw1FWozLzofDBUGvRptuyZY=";
|
||||||
|
|
||||||
|
outputs = [ "out" "patterns" ];
|
||||||
|
|
||||||
nativeBuildInputs = [installShellFiles];
|
nativeBuildInputs = [installShellFiles];
|
||||||
|
|
||||||
subPackages = [
|
subPackages = [
|
||||||
@@ -64,9 +66,13 @@ buildGoModule rec {
|
|||||||
postBuild = "mv $GOPATH/bin/{crowdsec-cli,cscli}";
|
postBuild = "mv $GOPATH/bin/{crowdsec-cli,cscli}";
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
|
mkdir -p $patterns
|
||||||
|
mv ./config/patterns/* $patterns
|
||||||
|
|
||||||
mkdir -p $out/share/crowdsec
|
mkdir -p $out/share/crowdsec
|
||||||
cp -r ./config $out/share/crowdsec/
|
cp -r ./config $out/share/crowdsec/
|
||||||
|
|
||||||
|
|
||||||
installShellCompletion --cmd cscli \
|
installShellCompletion --cmd cscli \
|
||||||
--bash <($out/bin/cscli completion bash) \
|
--bash <($out/bin/cscli completion bash) \
|
||||||
--fish <($out/bin/cscli completion fish) \
|
--fish <($out/bin/cscli completion fish) \
|
||||||
|
|||||||
Reference in New Issue
Block a user