forked from jan-leila/nix-config
		
	refactor: moved server module configs out of default.nix files
This commit is contained in:
		
							parent
							
								
									89793fca6a
								
							
						
					
					
						commit
						30a042d709
					
				
					 14 changed files with 381 additions and 367 deletions
				
			
		|  | @ -1,112 +1,10 @@ | |||
| { | ||||
|   lib, | ||||
|   config, | ||||
|   ... | ||||
| }: { | ||||
|   imports = [ | ||||
|     ./home-assistant.nix | ||||
|     ./proxy.nix | ||||
|     ./database.nix | ||||
|     ./fail2ban.nix | ||||
|     ./impermanence.nix | ||||
|     ./extensions | ||||
|   ]; | ||||
| 
 | ||||
|   options.services.home-assistant = { | ||||
|     database = lib.mkOption { | ||||
|       type = lib.types.enum [ | ||||
|         "builtin" | ||||
|         "postgres" | ||||
|       ]; | ||||
|       description = "what database do we want to use"; | ||||
|       default = "builtin"; | ||||
|     }; | ||||
| 
 | ||||
|     extensions = { | ||||
|       sonos = { | ||||
|         enable = lib.mkEnableOption "enable the sonos plugin"; | ||||
|         port = lib.mkOption { | ||||
|           type = lib.types.int; | ||||
|           default = 1400; | ||||
|           description = "what port to use for sonos discovery"; | ||||
|         }; | ||||
|       }; | ||||
|       jellyfin = { | ||||
|         enable = lib.mkEnableOption "enable the jellyfin plugin"; | ||||
|       }; | ||||
|       wyoming = { | ||||
|         enable = lib.mkEnableOption "enable wyoming"; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   config = lib.mkIf config.services.home-assistant.enable (lib.mkMerge [ | ||||
|     { | ||||
|       services.home-assistant = { | ||||
|         configDir = "/var/lib/hass"; | ||||
|         extraComponents = [ | ||||
|           "default_config" | ||||
|           "esphome" | ||||
|           "met" | ||||
|           "radio_browser" | ||||
|           "isal" | ||||
|           "zha" | ||||
|           "webostv" | ||||
|           "tailscale" | ||||
|           "syncthing" | ||||
|           "analytics_insights" | ||||
|           "unifi" | ||||
|           "openweathermap" | ||||
|           "ollama" | ||||
|           "mobile_app" | ||||
|           "logbook" | ||||
|           "ssdp" | ||||
|           "usb" | ||||
|           "webhook" | ||||
|           "bluetooth" | ||||
|           "dhcp" | ||||
|           "energy" | ||||
|           "history" | ||||
|           "backup" | ||||
|           "assist_pipeline" | ||||
|           "conversation" | ||||
|           "sun" | ||||
|           "zeroconf" | ||||
|           "cpuspeed" | ||||
|         ]; | ||||
|         config = { | ||||
|           http = { | ||||
|             server_port = 8123; | ||||
|             use_x_forwarded_for = true; | ||||
|             trusted_proxies = ["127.0.0.1" "::1"]; | ||||
|             ip_ban_enabled = true; | ||||
|             login_attempts_threshold = 10; | ||||
|           }; | ||||
|           homeassistant = { | ||||
|             external_url = "https://${config.services.home-assistant.domain}"; | ||||
|             # internal_url = "http://192.168.1.2:8123"; | ||||
|           }; | ||||
|           recorder.db_url = "postgresql://@/${config.services.home-assistant.configDir}"; | ||||
|           "automation manual" = []; | ||||
|           "automation ui" = "!include automations.yaml"; | ||||
|           mobile_app = {}; | ||||
|         }; | ||||
|         extraPackages = python3Packages: | ||||
|           with python3Packages; [ | ||||
|             hassil | ||||
|             numpy | ||||
|             gtts | ||||
|           ]; | ||||
|       }; | ||||
| 
 | ||||
|       # TODO: configure /var/lib/hass/secrets.yaml via sops | ||||
| 
 | ||||
|       networking.firewall.allowedUDPPorts = [ | ||||
|         1900 | ||||
|       ]; | ||||
| 
 | ||||
|       systemd.tmpfiles.rules = [ | ||||
|         "f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass" | ||||
|       ]; | ||||
|     } | ||||
|   ]); | ||||
| } | ||||
|  |  | |||
							
								
								
									
										104
									
								
								modules/nixos-modules/server/home-assistant/home-assistant.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								modules/nixos-modules/server/home-assistant/home-assistant.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,104 @@ | |||
| { | ||||
|   lib, | ||||
|   config, | ||||
|   ... | ||||
| }: { | ||||
|   options.services.home-assistant = { | ||||
|     database = lib.mkOption { | ||||
|       type = lib.types.enum [ | ||||
|         "builtin" | ||||
|         "postgres" | ||||
|       ]; | ||||
|       description = "what database do we want to use"; | ||||
|       default = "builtin"; | ||||
|     }; | ||||
| 
 | ||||
|     extensions = { | ||||
|       sonos = { | ||||
|         enable = lib.mkEnableOption "enable the sonos plugin"; | ||||
|         port = lib.mkOption { | ||||
|           type = lib.types.int; | ||||
|           default = 1400; | ||||
|           description = "what port to use for sonos discovery"; | ||||
|         }; | ||||
|       }; | ||||
|       jellyfin = { | ||||
|         enable = lib.mkEnableOption "enable the jellyfin plugin"; | ||||
|       }; | ||||
|       wyoming = { | ||||
|         enable = lib.mkEnableOption "enable wyoming"; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   config = lib.mkIf config.services.home-assistant.enable (lib.mkMerge [ | ||||
|     { | ||||
|       services.home-assistant = { | ||||
|         configDir = "/var/lib/hass"; | ||||
|         extraComponents = [ | ||||
|           "default_config" | ||||
|           "esphome" | ||||
|           "met" | ||||
|           "radio_browser" | ||||
|           "isal" | ||||
|           "zha" | ||||
|           "webostv" | ||||
|           "tailscale" | ||||
|           "syncthing" | ||||
|           "analytics_insights" | ||||
|           "unifi" | ||||
|           "openweathermap" | ||||
|           "ollama" | ||||
|           "mobile_app" | ||||
|           "logbook" | ||||
|           "ssdp" | ||||
|           "usb" | ||||
|           "webhook" | ||||
|           "bluetooth" | ||||
|           "dhcp" | ||||
|           "energy" | ||||
|           "history" | ||||
|           "backup" | ||||
|           "assist_pipeline" | ||||
|           "conversation" | ||||
|           "sun" | ||||
|           "zeroconf" | ||||
|           "cpuspeed" | ||||
|         ]; | ||||
|         config = { | ||||
|           http = { | ||||
|             server_port = 8123; | ||||
|             use_x_forwarded_for = true; | ||||
|             trusted_proxies = ["127.0.0.1" "::1"]; | ||||
|             ip_ban_enabled = true; | ||||
|             login_attempts_threshold = 10; | ||||
|           }; | ||||
|           homeassistant = { | ||||
|             external_url = "https://${config.services.home-assistant.domain}"; | ||||
|             # internal_url = "http://192.168.1.2:8123"; | ||||
|           }; | ||||
|           recorder.db_url = "postgresql://@/${config.services.home-assistant.configDir}"; | ||||
|           "automation manual" = []; | ||||
|           "automation ui" = "!include automations.yaml"; | ||||
|           mobile_app = {}; | ||||
|         }; | ||||
|         extraPackages = python3Packages: | ||||
|           with python3Packages; [ | ||||
|             hassil | ||||
|             numpy | ||||
|             gtts | ||||
|           ]; | ||||
|       }; | ||||
| 
 | ||||
|       # TODO: configure /var/lib/hass/secrets.yaml via sops | ||||
| 
 | ||||
|       networking.firewall.allowedUDPPorts = [ | ||||
|         1900 | ||||
|       ]; | ||||
| 
 | ||||
|       systemd.tmpfiles.rules = [ | ||||
|         "f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass" | ||||
|       ]; | ||||
|     } | ||||
|   ]); | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue