{ config, pkgs, lib, ... }: with lib; let helper = import ./lib.nix { inherit config pkgs lib; }; cfg = config.numbus.services.home-assistant; in helper.mkPodmanService { name = "home-assistant"; description = "Home Assistant, libre house control and much more"; defaultPort = "8123"; pod = "home-assistant"; dataDir = false; extraOptions = { devices = mkOption { type = types.listOf types.str; default = []; example = [ "/dev/serial/by-id/Sonoff_Zigbee_3.0-id-port0:/dev/ttyUSB0" ]; description = "List of devices to map into the container. /dev/ttyUSB0 is used for Zigbee dongles"; }; }; extraConfig = { }; composeText = '' services: home-assistant: image: ghcr.io/home-assistant/home-assistant:latest container_name: home-assistant hostname: home-assistant networks: home-assistant: ports: - "${cfg.port}:8123/tcp" volumes: - ${cfg.configDir}:/config - /etc/localtime:/etc/localtime:ro - /run/dbus:/run/dbus:ro ${lib.optionalString (cfg.devices != []) '' devices: ${lib.concatStringsSep "\n" (map (d: " - \"${d}\"") cfg.devices)} ''} restart: unless-stopped home-assistant-mqtt: image: docker.io/library/eclipse-mosquitto:latest container_name: home-assistant-mqtt hostname: home-assistant-mqtt networks: home-assistant: volumes: - /mnt/config/mosquitto:/mosquitto restart: unless-stopped networks: home-assistant: name: home-assistant driver: bridge ''; }