{ 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"; dependencies = [ "traefik.service" "${config.numbus.services.dns}.service" ]; 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"; }; }; composeText = '' services: home-assistant: image: ghcr.io/home-assistant/home-assistant:latest container_name: home-assistant hostname: home-assistant networks: home-assistant_frontend: home-assistant_backend: 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_backend: volumes: - /mnt/config/mosquitto:/mosquitto restart: unless-stopped networks: home-assistant_frontend: name: home-assistant_frontend driver: bridge ipam: config: - subnet: "10.89.5.0/24" gateway: "10.89.5.254" home-assistant_backend: name: home-assistant_backend driver: bridge ipam: config: - subnet: "10.89.6.0/24" gateway: "10.89.6.254" ''; }