forked from CCCHH/nix-infra
		
	Add esphome host
This commit is contained in:
		
					parent
					
						
							
								5803c6ddc6
							
						
					
				
			
			
				commit
				
					
						26a1fe0e84
					
				
			
		
					 5 changed files with 82 additions and 0 deletions
				
			
		
							
								
								
									
										8
									
								
								config/hosts/esphome/configuration.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								config/hosts/esphome/configuration.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
{ ... }:
 | 
			
		||||
{
 | 
			
		||||
  networking = {
 | 
			
		||||
    hostName = "esphome";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  system.stateVersion = "23.05";
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								config/hosts/esphome/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								config/hosts/esphome/default.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
{ ... }:
 | 
			
		||||
{
 | 
			
		||||
  imports = [
 | 
			
		||||
    ./configuration.nix
 | 
			
		||||
    ./esphome.nix
 | 
			
		||||
    ./nginx.nix
 | 
			
		||||
  ];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								config/hosts/esphome/esphome.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								config/hosts/esphome/esphome.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
{ ... }:
 | 
			
		||||
{
 | 
			
		||||
  services.esphome = {
 | 
			
		||||
    enable = true;
 | 
			
		||||
    openFirewall = true;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								config/hosts/esphome/nginx.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								config/hosts/esphome/nginx.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
{ config, ... }:
 | 
			
		||||
{
 | 
			
		||||
  services.nginx = {
 | 
			
		||||
    enable = true;
 | 
			
		||||
 | 
			
		||||
    virtualHosts = {
 | 
			
		||||
      "acme-esphome.ccchh.net" = {
 | 
			
		||||
        enableACME = true;
 | 
			
		||||
        serverName = "esphome.ccchh.net";
 | 
			
		||||
 | 
			
		||||
        listen = [
 | 
			
		||||
          {
 | 
			
		||||
            addr = "0.0.0.0";
 | 
			
		||||
            port = 31820;
 | 
			
		||||
          }
 | 
			
		||||
        ];
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      "esphome.ccchh.net" = {
 | 
			
		||||
        forceSSL = true;
 | 
			
		||||
        useACMEHost = "esphome.ccchh.net";
 | 
			
		||||
 | 
			
		||||
        listen = [
 | 
			
		||||
          {
 | 
			
		||||
            addr = "0.0.0.0";
 | 
			
		||||
            port = 80;
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            addr = "0.0.0.0";
 | 
			
		||||
            port = 443;
 | 
			
		||||
            ssl = true;
 | 
			
		||||
          }
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        locations."/" = {
 | 
			
		||||
          proxyPass = "http://${config.services.esphome.address}:${builtins.toString config.services.esphome.port}";
 | 
			
		||||
          proxyWebsockets = true;
 | 
			
		||||
        };
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
  
 | 
			
		||||
  networking.firewall.allowedTCPPorts = [ 80 443 31820 ];
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue