{ pkgs, lib, config, ... }: # no need to set ZIGBEE2MQTT_DATA anymore assert lib.versionOlder lib.version "21.03"; let unstable = import { }; in { imports = [ ./mqtt.nix ./zigbee2mqtt/buttons.nix ./zigbee2mqtt/configurationHelper.nix ./zigbee2mqtt/doors.nix ./zigbee2mqtt/fyrtur.nix ./zigbee2mqtt/heater.nix ./zigbee2mqtt/leds.nix ./zigbee2mqtt/lights.nix ./zigbee2mqtt/motion.nix ./zigbee2mqtt/repeater.nix ./zigbee2mqtt/temperatur.nix ]; services.zigbee2mqtt = { enable = true; #package = pkgs.own_zigbee2mqtt; package = unstable.zigbee2mqtt; config = { # Home Assistant integration (MQTT discovery) homeassistant = false; # allow new devices to join permit_join = true; # MQTT settings mqtt = { # MQTT base topic for zigbee2mqtt MQTT messages base_topic = "zigbee2mqtt"; # MQTT server URL server = "mqtt://127.0.0.1:1883"; # MQTT server authentication, uncomment if required: user = "zigbee"; password = lib.fileContents ; }; # Serial settings serial = { #port = "/dev/ttyACM0"; port = "/dev/ttyUSB0"; # disable LED of CC2531 USB sniffer #disable_led = true; }; # you own network key, # 16 numbers between 0 and 255 # see https://www.zigbee2mqtt.io/how_tos/how_to_secure_network.html advanced.network_key = import ; advanced.log_output = [ "console" ]; advanced.pan_id = 1337; # configure web ui frontend.port = 9666; frontend.host = "0.0.0.0"; experimental.new_api = true; }; }; systemd.services.zigbee2mqtt.environment = { ZIGBEE2MQTT_DATA = "/var/lib/zigbee2mqtt"; }; services.nginx = { enable = true; recommendedProxySettings = true; virtualHosts = { "zigbee2mqtt.pepe.private" = { serverAliases = [ "zigbee.pepe.private" ]; locations."/" = { proxyPass = "http://localhost:${ toString config.services.zigbee2mqtt.config.frontend.port }"; proxyWebsockets = true; }; }; }; }; }