Skip to content

Mosquitto

Mosquitto provides a lightweight local MQTT broker for development and testing.

Enable it with:

{ ... }:

{
  services.mosquitto.enable = true;
}

By default, the broker listens on 127.0.0.1 and uses port 1883 through devenv's dynamic port allocation. The resolved port is exposed as MOSQUITTO_PORT, and the configured host is exposed as MOSQUITTO_HOST.

You can customize the listener or append native Mosquitto configuration:

{ ... }:

{
  services.mosquitto = {
    enable = true;
    bind = "127.0.0.1";
    port = 1883;
    extraConfig = ''
      max_queued_messages 1000
    '';
  };
}

extraConfig is appended to the generated mosquitto.conf.

Options

services.mosquitto.enable

Whether to enable mosquitto MQTT broker.

Type: boolean

Default:

false

Example:

true

Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/mosquitto.nix

services.mosquitto.package

Which package of mosquitto to use

Type: package

Default:

pkgs.mosquitto

Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/mosquitto.nix

services.mosquitto.bind

The IP interface to bind to. null means “all interfaces”.

Type: null or string

Default:

"127.0.0.1"

Example:

"127.0.0.1"

Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/mosquitto.nix

services.mosquitto.extraConfig

Additional text to append to mosquitto.conf.

Type: strings concatenated with “\n”

Default:

""

Example:

''
  max_queued_messages 1000
''

Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/mosquitto.nix

services.mosquitto.port

The TCP port to accept MQTT connections.

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Default:

1883

Declared by: - https://github.com/cachix/devenv/blob/main/src/modules/services/mosquitto.nix