43 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
{
 | 
						|
  lib,
 | 
						|
  config,
 | 
						|
  ...
 | 
						|
}: {
 | 
						|
  options.services.home-assistant = {
 | 
						|
    domain = lib.mkOption {
 | 
						|
      type = lib.types.str;
 | 
						|
      description = "domain that home-assistant will be hosted at";
 | 
						|
      default = "home-assistant.arpa";
 | 
						|
    };
 | 
						|
    extraDomains = lib.mkOption {
 | 
						|
      type = lib.types.listOf lib.types.str;
 | 
						|
      description = "extra domains that should be configured for home-assistant";
 | 
						|
      default = [];
 | 
						|
    };
 | 
						|
    reverseProxy = {
 | 
						|
      enable = lib.mkOption {
 | 
						|
        type = lib.types.bool;
 | 
						|
        default = config.services.reverseProxy.enable && config.services.home-assistant.enable;
 | 
						|
      };
 | 
						|
    };
 | 
						|
  };
 | 
						|
 | 
						|
  config = lib.mkIf config.services.home-assistant.reverseProxy.enable {
 | 
						|
    services.reverseProxy.services.home-assistant = {
 | 
						|
      target = "http://localhost:${toString config.services.home-assistant.config.http.server_port}";
 | 
						|
      domain = config.services.home-assistant.domain;
 | 
						|
      extraDomains = config.services.home-assistant.extraDomains;
 | 
						|
 | 
						|
      settings = {
 | 
						|
        proxyWebsockets.enable = true;
 | 
						|
        forwardHeaders.enable = true;
 | 
						|
 | 
						|
        # Custom timeout settings
 | 
						|
        proxyHeaders = {
 | 
						|
          enable = true;
 | 
						|
          timeout = 90;
 | 
						|
        };
 | 
						|
      };
 | 
						|
    };
 | 
						|
  };
 | 
						|
}
 |