{ config, lib, ... }:

with lib;

let
  cfg = config.settings.containers.homeassistant;
in {
  options = {
    settings.containers.homeassistant.enable = lib.mkOption {
      type = lib.types.bool;
      default = false;
      description = ''
        Enable storage configuration
      '';
    };
  };

  config = mkIf cfg.enable {
    services.podman.containers.homeassistant = {
      image = "ghcr.io/home-assistant/home-assistant:stable";
      network = "proxy";
      volumes = [
        "%h/containers/homeassistant/config:/config" 
      ];
      userNS = "keep-id";
      environment = {
        TZ = "Europe/Amsterdam";
      };
    };

    settings.containers.caddy.routes.tbmrs-local.routes.home-assistant = {
      host = "home-assistant";
      url = "homeassistant:8123"; 
    };
  };
}
