minio: 2025-01-18T00-31-37Z -> 2025-01-20T14-49-07Z
[NixPkgs.git] / pkgs / by-name / cr / crowdsec / package.nix
blob4c3a030b9e34628dc580c8ec0ebae3b016a1d95b
2   lib,
3   buildGoModule,
4   fetchFromGitHub,
5   installShellFiles,
6 }:
8 buildGoModule rec {
9   pname = "crowdsec";
10   version = "1.6.4";
12   src = fetchFromGitHub {
13     owner = "crowdsecurity";
14     repo = pname;
15     tag = "v${version}";
16     hash = "sha256-U3YnLjsD+Kl/6HD+RPP0gWa4N96X5wkbdCmIrxas1I8=";
17   };
19   vendorHash = "sha256-PtBVXPbLNdJyS8v8H9eRB6sTPaiseg18+eXToHvH7tw=";
21   nativeBuildInputs = [ installShellFiles ];
23   subPackages = [
24     "cmd/crowdsec"
25     "cmd/crowdsec-cli"
26   ];
28   ldflags = [
29     "-s"
30     "-w"
31     "-X github.com/crowdsecurity/go-cs-lib/version.Version=v${version}"
32     "-X github.com/crowdsecurity/go-cs-lib/version.BuildDate=1970-01-01_00:00:00"
33     "-X github.com/crowdsecurity/go-cs-lib/version.Tag=${src.rev}"
34     "-X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=alphaga"
35     "-X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultConfigDir=/etc/crowdsec"
36     "-X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultDataDir=/var/lib/crowdsec/data"
37   ];
39   postBuild = "mv $GOPATH/bin/{crowdsec-cli,cscli}";
41   postInstall = ''
42     mkdir -p $out/share/crowdsec
43     cp -r ./config $out/share/crowdsec/
45     installShellCompletion --cmd cscli \
46       --bash <($out/bin/cscli completion bash) \
47       --fish <($out/bin/cscli completion fish) \
48       --zsh <($out/bin/cscli completion zsh)
49   '';
51   # It's important that the version is correctly set as it also determines feature capabilities
52   checkPhase = ''
53     $GOPATH/bin/cscli version 2>&1 | grep -q "version: v${version}"
54   '';
56   meta = with lib; {
57     homepage = "https://crowdsec.net/";
58     changelog = "https://github.com/crowdsecurity/crowdsec/releases/tag/v${version}";
59     description = "CrowdSec is a free, open-source and collaborative IPS";
60     longDescription = ''
61       CrowdSec is a free, modern & collaborative behavior detection engine,
62       coupled with a global IP reputation network. It stacks on fail2ban's
63       philosophy but is IPV6 compatible and 60x faster (Go vs Python), uses Grok
64       patterns to parse logs and YAML scenario to identify behaviors. CrowdSec
65       is engineered for modern Cloud/Containers/VM based infrastructures (by
66       decoupling detection and remediation). Once detected you can remedy
67       threats with various bouncers (firewall block, nginx http 403, Captchas,
68       etc.) while the aggressive IP can be sent to CrowdSec for curation before
69       being shared among all users to further improve everyone's security.
70     '';
71     license = licenses.mit;
72     maintainers = with maintainers; [
73       jk
74       urandom
75     ];
76   };