diff --git a/hosts/nixedo/homelab.nix b/hosts/nixedo/homelab.nix index cd08e4d6..5ddb8541 100644 --- a/hosts/nixedo/homelab.nix +++ b/hosts/nixedo/homelab.nix @@ -18,6 +18,7 @@ }; gitea-actions-runner.enable = true; + home-assistant.enable = true; homepage-dashboard = { enable = true; diff --git a/hosts/nixedo/modules/acme.nix b/hosts/nixedo/modules/acme.nix index 3e4e863f..cb6aaac9 100644 --- a/hosts/nixedo/modules/acme.nix +++ b/hosts/nixedo/modules/acme.nix @@ -26,6 +26,7 @@ "code" "eric" "florida-drupalcamp-tailwind-css" + "home" "jellyfin" "luke" "nixedo" diff --git a/hosts/nixedo/modules/default.nix b/hosts/nixedo/modules/default.nix index d5be97bb..67db8b36 100644 --- a/hosts/nixedo/modules/default.nix +++ b/hosts/nixedo/modules/default.nix @@ -18,6 +18,7 @@ with lib; ./cloudflared.nix ./containers ./forgejo.nix + ./home-assistant.nix ./immich.nix ./jellyfin.nix ./nginx diff --git a/hosts/nixedo/modules/home-assistant.nix b/hosts/nixedo/modules/home-assistant.nix new file mode 100644 index 00000000..02a3b9cb --- /dev/null +++ b/hosts/nixedo/modules/home-assistant.nix @@ -0,0 +1,86 @@ +{ config, lib, ... }: + +with lib; + +let + cfg = homelab.services.${service}; + homelab = config.homelab; + service = "home-assistant"; +in +{ + options.homelab.services.${service} = { + enable = mkEnableOption "Enable ${service}"; + + url = mkOption { + default = "home.${homelab.domain}"; + type = types.str; + }; + + homepage.name = mkOption { + default = "Home Assisant"; + type = types.str; + }; + + homepage.description = mkOption { + default = "Open source home automation that puts local control and privacy first."; + type = types.str; + }; + + homepage.icon = mkOption { + default = "home-assistant"; + type = types.str; + }; + + homepage.category = mkOption { + default = "Services"; + type = types.str; + }; + }; + + config = mkIf cfg.enable { + services = { + home-assistant = { + enable = true; + + config = { + external_url = "https://home.${homelab.domain}"; + name = "Home"; + time_zone = "Europe/London"; + unit_system = "metric"; + + http = { + trusted_proxies = [ + "127.0.0.1" + "::1" + ]; + use_x_forwarded_for = true; + }; + }; + + extraComponents = [ + "default_config" + "elgato" + "hive" + "met" + "mobile_app" + "sia" + "weather" + "webostv" + ]; + + openFirewall = true; + }; + + nginx.virtualHosts."${cfg.url}" = { + forceSSL = true; + useACMEHost = homelab.domain; + + locations."/" = { + proxyPass = "http://localhost:${toString config.services.${service}.config.http.server_port}"; + proxyWebsockets = true; + recommendedProxySettings = true; + }; + }; + }; + }; +}