Add uniqueness check for ports

Credit to https://lorenzbischof.ch/posts/detect-port-conflicts-in-nixos-services/
This commit is contained in:
SebastianStork 2025-06-14 01:13:37 +02:00
parent a4c3e2a829
commit 232c9aa946
21 changed files with 110 additions and 12 deletions

View file

@ -19,6 +19,10 @@ in
type = lib.types.port;
default = 8080;
};
prometheusPort = lib.mkOption {
type = lib.types.port;
default = 6060;
};
sources = lib.mkOption {
type = lib.types.listOf (
lib.types.enum [
@ -32,6 +36,11 @@ in
};
config = lib.mkIf cfg.enable {
meta.ports.list = [
cfg.apiPort
cfg.prometheusPort
];
nixpkgs.overlays = [ inputs.crowdsec.overlays.default ];
sops.secrets."crowdsec/enrollment-key".owner = user;
@ -42,7 +51,10 @@ in
enable = true;
package = inputs.crowdsec.packages.${pkgs.system}.crowdsec;
enrollKeyFile = config.sops.secrets."crowdsec/enrollment-key".path;
settings.api.server.listen_uri = "127.0.0.1:${toString cfg.apiPort}";
settings = {
api.server.listen_uri = "127.0.0.1:${toString cfg.apiPort}";
cscli.prometheus_uri = "http://127.0.0.1:${toString cfg.prometheusPort}";
};
allowLocalJournalAccess = true;
acquisitions =