mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 17:31:34 +01:00
crowdsec: Split module into two files again
This commit is contained in:
parent
e23111b6d7
commit
6a67e1f483
3 changed files with 142 additions and 130 deletions
39
modules/system/services/crowdsec/bouncers.nix
Normal file
39
modules/system/services/crowdsec/bouncers.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
config,
|
||||
inputs,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.crowdsec;
|
||||
in
|
||||
{
|
||||
imports = [ inputs.crowdsec.nixosModules.crowdsec-firewall-bouncer ];
|
||||
|
||||
options.custom.services.crowdsec.bouncers.firewall = lib.mkEnableOption "";
|
||||
|
||||
config = lib.mkIf cfg.bouncers.firewall {
|
||||
services.crowdsec-firewall-bouncer = {
|
||||
enable = true;
|
||||
package = inputs.crowdsec.packages.${pkgs.system}.crowdsec-firewall-bouncer;
|
||||
settings = {
|
||||
api_key = "cs-firewall-bouncer";
|
||||
api_url = "http://localhost:${builtins.toString cfg.apiPort}";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.crowdsec.serviceConfig.ExecStartPre = lib.mkAfter (
|
||||
lib.getExe (
|
||||
pkgs.writeShellApplication {
|
||||
name = "crowdsec-add-bouncer";
|
||||
text = ''
|
||||
if ! cscli bouncers list | grep -q "firewall"; then
|
||||
cscli bouncers add "firewall" --key "cs-firewall-bouncer"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue