fix(rpi4): adapt to new mosquitto config structure

This commit is contained in:
Felix Schröter 2021-11-23 00:12:41 +01:00
parent 33cab5d19e
commit f2c49827c2
No known key found for this signature in database
GPG key ID: 910ACB9F6BD26F58

View file

@ -4,7 +4,7 @@ with pkgs;
let let
mqttDomain = "mqtt.${config.networking.domain}"; mqttDomain = "mqtt.${config.networking.domain}";
mqttWSPort = "9001"; mqttWSPort = 9001;
in { in {
# just installed for ConBee firmware updates # just installed for ConBee firmware updates
environment.systemPackages = with pkgs; [ deconz ]; environment.systemPackages = with pkgs; [ deconz ];
@ -15,7 +15,7 @@ in {
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;
locations."/" = { locations."/" = {
proxyPass = "http://localhost:${mqttWSPort}"; proxyPass = "http://localhost:${toString mqttWSPort}";
proxyWebsockets = true; proxyWebsockets = true;
}; };
}; };
@ -30,42 +30,40 @@ in {
}; };
}; };
networking.firewall.allowedTCPPorts = [ config.services.mosquitto.port ]; networking.firewall.allowedTCPPorts = [ mqttWSPort ];
services.mosquitto = { services.mosquitto = {
enable = true; enable = true;
host = "0.0.0.0"; listeners = [{
checkPasswords = true; port = mqttWSPort;
extraConf = '' settings.protocol = "websockets";
listener ${mqttWSPort}
protocol websockets
'';
users = { users = {
"hass" = { "hass" = {
acl = [ acl = [
"topic readwrite homeassistant/#" "readwrite homeassistant/#"
"topic readwrite tasmota/#" "readwrite tasmota/#"
"topic readwrite owntracks/#" "readwrite owntracks/#"
]; ];
hashedPasswordFile = "/etc/nixos/secrets/mqtt/hass"; hashedPasswordFile = "/etc/nixos/secrets/mqtt/hass";
}; };
"tasmota" = { "tasmota" = {
acl = [ "topic readwrite tasmota/#" "topic readwrite homeassistant/#" ]; acl = [ "readwrite tasmota/#" "readwrite homeassistant/#" ];
hashedPasswordFile = "/etc/nixos/secrets/mqtt/tasmota"; hashedPasswordFile = "/etc/nixos/secrets/mqtt/tasmota";
}; };
"owntracks" = { "owntracks" = {
acl = [ "topic readwrite owntracks/#" ]; acl = [ "readwrite owntracks/#" ];
hashedPasswordFile = "/etc/nixos/secrets/mqtt/owntracks"; hashedPasswordFile = "/etc/nixos/secrets/mqtt/owntracks";
}; };
"felix" = { "felix" = {
acl = [ "topic read owntracks/#" "topic readwrite owntracks/felix/#" ]; acl = [ "read owntracks/#" "readwrite owntracks/felix/#" ];
hashedPasswordFile = "/etc/nixos/secrets/mqtt/felix"; hashedPasswordFile = "/etc/nixos/secrets/mqtt/felix";
}; };
"birgit" = { "birgit" = {
acl = [ "topic read owntracks/#" "topic readwrite owntracks/birgit/#" ]; acl = [ "read owntracks/#" "readwrite owntracks/birgit/#" ];
hashedPasswordFile = "/etc/nixos/secrets/mqtt/birgit"; hashedPasswordFile = "/etc/nixos/secrets/mqtt/birgit";
}; };
}; };
}];
}; };
services.home-assistant = { services.home-assistant = {
@ -107,7 +105,7 @@ in {
}; };
mqtt = { mqtt = {
broker = "localhost"; broker = "localhost";
port = config.services.mosquitto.port; port = mqttWSPort;
username = "hass"; username = "hass";
password = "!secret mqtt_password"; password = "!secret mqtt_password";
discovery = true; discovery = true;