33 lines
		
	
	
	
		
			843 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			843 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
{
 | 
						|
  lib,
 | 
						|
  config,
 | 
						|
  ...
 | 
						|
}: {
 | 
						|
  options.services.home-assistant = {
 | 
						|
    subdomain = lib.mkOption {
 | 
						|
      type = lib.types.str;
 | 
						|
      description = "subdomain of base domain that home-assistant will be hosted at";
 | 
						|
      default = "home-assistant";
 | 
						|
    };
 | 
						|
  };
 | 
						|
 | 
						|
  config = lib.mkIf (config.host.reverse_proxy.enable && config.services.home-assistant.enable) {
 | 
						|
    host = {
 | 
						|
      reverse_proxy.subdomains.${config.services.home-assistant.subdomain} = {
 | 
						|
        target = "http://localhost:${toString config.services.home-assistant.config.http.server_port}";
 | 
						|
 | 
						|
        websockets.enable = true;
 | 
						|
        forwardHeaders.enable = true;
 | 
						|
 | 
						|
        extraConfig = ''
 | 
						|
          add_header Upgrade $http_upgrade;
 | 
						|
          add_header Connection \"upgrade\";
 | 
						|
 | 
						|
          proxy_buffering off;
 | 
						|
 | 
						|
          proxy_read_timeout 90;
 | 
						|
        '';
 | 
						|
      };
 | 
						|
    };
 | 
						|
  };
 | 
						|
}
 |