# nats

## Options

### services.nats.enable

Whether to enable the NATS messaging server.

NATS is a simple, secure and high performance messaging system for cloud native applications, IoT messaging, and microservices architectures.

*Type:* boolean

*Default:*

```nix
false
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.package

Which NATS server package to use.

*Type:* package

*Default:*

```nix
pkgs.nats-server
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.authorization.enable

Whether to enable authorization for client connections.

*Type:* boolean

*Default:*

```nix
false
```

*Example:*

```nix
true
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.authorization.password

Password required for client connections. Only used if authorization is enabled. Warning: This will be visible in the Nix store.

*Type:* string

*Default:*

```nix
""
```

*Example:*

```nix
"nats-pass"
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.authorization.token

Token required for client connections. Alternative to user/password authentication. Warning: This will be visible in the Nix store.

*Type:* string

*Default:*

```nix
""
```

*Example:*

```nix
"my-secret-token"
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.authorization.user

Username required for client connections. Only used if authorization is enabled.

*Type:* string

*Default:*

```nix
""
```

*Example:*

```nix
"nats-user"
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.clientAdvertise

Client URL to advertise to other servers in a cluster. Useful when running behind NAT or in containers.

*Type:* string

*Default:*

```nix
""
```

*Example:*

```nix
"localhost:4222"
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.debug

Enable debug logging for troubleshooting.

*Type:* boolean

*Default:*

```nix
false
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.host

Network host to listen on for client connections. Set to “0.0.0.0” to listen on all interfaces. Default is localhost for security.

*Type:* string

*Default:*

```nix
"127.0.0.1"
```

*Example:*

```nix
"0.0.0.0"
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.jetstream.enable

Whether to enable JetStream persistence layer for streaming and queues.

*Type:* boolean

*Default:*

```nix
false
```

*Example:*

```nix
true
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.jetstream.maxFileStore

Maximum disk space for file-based streams. Use suffixes: K, M, G, T for sizes.

*Type:* string

*Default:*

```nix
"10G"
```

*Example:*

```nix
"100G"
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.jetstream.maxMemory

Maximum memory for in-memory streams. Use suffixes: K, M, G, T for sizes.

*Type:* string

*Default:*

```nix
"1G"
```

*Example:*

```nix
"512M"
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.logFile

Path to log file. If empty, logs to stdout. Stdout is recommended for devenv as logs are captured by process manager.

*Type:* string

*Default:*

```nix
""
```

*Example:*

```nix
"/var/log/nats-server.log"
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.monitoring.enable

Enable HTTP monitoring endpoint. Provides /healthz, /varz, /connz, and other monitoring endpoints. Highly recommended for production deployments.

*Type:* boolean

*Default:*

```nix
true
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.monitoring.port

Port for HTTP monitoring endpoint. Access monitoring at `http://host:port/varz`

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

*Default:*

```nix
8222
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.port

Port to listen on for client connections.

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

*Default:*

```nix
4222
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.serverName

Server name for identification in clusters. If empty, NATS will auto-generate a unique name.

*Type:* string

*Default:*

```nix
""
```

*Example:*

```nix
"nats-dev-1"
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.settings

Additional NATS server configuration as a Nix attribute set. This will be converted to NATS config file format.

Use this for advanced features like:

* TLS/SSL configuration
* Clustering with routes
* MQTT gateway
* WebSocket support
* Custom authorization

See <https://docs.nats.io/running-a-nats-service/configuration>

*Type:* attribute set

*Default:*

```nix
{ }
```

*Example:*

```nix
{
  tls = {
    cert_file = "/path/to/cert.pem";
    key_file = "/path/to/key.pem";
    verify = true;
  };
  cluster = {
    name = "my-cluster";
    listen = "0.0.0.0:6222";
    routes = [
      "nats://node1:6222"
      "nats://node2:6222"
    ];
  };
}
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>

### services.nats.trace

Enable protocol tracing for deep debugging. Warning: Very verbose output.

*Type:* boolean

*Default:*

```nix
false
```

*Declared by:*

* <https://github.com/cachix/devenv/blob/main/src/modules/services/nats.nix>