# Sources for this configuration:
# - https://search.nixos.org/options?sort=relevance&type=packages&query=services.mosquitto
# - https://mosquitto.org/man/mosquitto-conf-5.html
# - https://winkekatze24.de
{ ... }:

{
  services.mosquitto = {
    enable = true;
    persistence = true;

    # set config for all listeners
    listeners = [{
      settings.allow_anonymous = true;
      omitPasswordAuth = true;
      acl = [ "topic readwrite #" ];
    }];

    bridges.winkekatz = {
      addresses = [
        { address = "mqtt.winkekatze24.de"; }
      ];
      topics = [
        "winkekatze/allcats/eye/set in 2"
        "winkekatze/allcats in 2"
        "+/status out 2 winkekatze/ \"\""
        "+/connected out 2 winkekatze/ \"\""
      ];
    };
  };

  networking.firewall.allowedTCPPorts = [ 1883 ];
}