From 8d4f1eb419d8befbba5ac91053046ea7b953750b Mon Sep 17 00:00:00 2001 From: Jordan Holt Date: Mon, 10 Mar 2025 16:24:34 +0000 Subject: [PATCH] home-assistant: move out of module --- hosts/pi/default.nix | 2 +- hosts/pi/home-assistant/default.nix | 297 +++++++++++++++++ .../pi}/home-assistant/floorplan/default.nix | 0 .../pi}/home-assistant/floorplan/style.css | 0 .../pi}/home-assistant/mqtt.nix | 0 .../nixos/services/home-assistant/default.nix | 306 ------------------ 6 files changed, 298 insertions(+), 307 deletions(-) create mode 100644 hosts/pi/home-assistant/default.nix rename {modules/nixos/services => hosts/pi}/home-assistant/floorplan/default.nix (100%) rename {modules/nixos/services => hosts/pi}/home-assistant/floorplan/style.css (100%) rename {modules/nixos/services => hosts/pi}/home-assistant/mqtt.nix (100%) delete mode 100644 modules/nixos/services/home-assistant/default.nix diff --git a/hosts/pi/default.nix b/hosts/pi/default.nix index c60d182..5373c31 100644 --- a/hosts/pi/default.nix +++ b/hosts/pi/default.nix @@ -8,6 +8,7 @@ imports = [ self.inputs.nixos-hardware.nixosModules.raspberry-pi-4 ./hardware-configuration.nix + ./home-assistant ../server.nix ]; @@ -124,7 +125,6 @@ enable = true; repoPath = "ssh://qcw86s11@qcw86s11.repo.borgbase.com/./repo"; }; - home-assistant.enable = true; }; }; diff --git a/hosts/pi/home-assistant/default.nix b/hosts/pi/home-assistant/default.nix new file mode 100644 index 0000000..6a9ecf1 --- /dev/null +++ b/hosts/pi/home-assistant/default.nix @@ -0,0 +1,297 @@ +{ + config, + pkgs, + self, + ... +}: + +{ + imports = [ + ./floorplan/default.nix + ./mqtt.nix + ]; + + age.secrets."files/services/home-assistant/secrets.yaml" = { + file = "${self.inputs.secrets}/files/services/home-assistant/secrets.yaml.age"; + path = "${config.services.home-assistant.configDir}/secrets.yaml"; + owner = "hass"; + group = "hass"; + }; + + services.home-assistant = { + enable = true; + + config = { + automation = "!include automations.yaml"; + backup = { }; + binary_sensor = [ ]; + default_config = { }; + http = { + server_host = "::1"; + trusted_proxies = [ "::1" ]; + use_x_forwarded_for = true; + }; + ffmpeg = { }; + homeassistant = { + name = "Home"; + latitude = "!secret latitude"; + longitude = "!secret longitude"; + country = "GB"; + temperature_unit = "C"; + time_zone = config.time.timeZone; + unit_system = "metric"; + auth_providers = [ + { + type = "trusted_networks"; + trusted_networks = [ + "100.64.0.0/10" + "127.0.0.1" + ]; + allow_bypass_login = true; + } + { + type = "homeassistant"; + } + ]; + }; + logger = { + default = "info"; + logs = { }; + }; + lovelace = { + mode = "yaml"; + }; + media_player = [ ]; + mobile_app = { }; + onkyo = { }; + open_meteo = { }; + recorder = { + purge_keep_days = 365; + }; + scene = "!include scenes.yaml"; + script = "!include scripts.yaml"; + sensor = [ ]; + system_health = { }; + zeroconf = { }; + }; + + extraComponents = [ + "air_quality" + "airly" + "alert" + "api" + "application_credentials" + "asuswrt" + "auth" + "automation" + "bayesian" + "binary_sensor" + # "blackbird" + "blueprint" + "bluetooth_adapters" + "bluetooth_le_tracker" + "button" + "calendar" + "camera" + "cast" + "cert_expiry" + "climate" + "co2signal" + "color_extractor" + "command_line" + "compensation" + "configurator" + "counter" + "cover" + "cpuspeed" + "default_config" + "demo" + "derivative" + "device_automation" + "device_sun_light_trigger" + "device_tracker" + "dlna_dmr" + "dlna_dms" + "dnsip" + "esphome" + "fail2ban" + "fan" + "feedreader" + "ffmpeg" + "file" + "file_upload" + "filesize" + "folder" + "folder_watcher" + "forecast_solar" + "frontend" + "gdacs" + "generic" + "generic_hygrostat" + "generic_thermostat" + "geo_json_events" + "geo_location" + "geo_rss_events" + "github" + "group" + "hardware" + "hdmi_cec" + "history_stats" + "homeassistant" + "homekit" + "homekit_controller" + "html5" + "http" + "humidifier" + "icloud" + "image_processing" + "input_boolean" + "input_button" + "input_datetime" + "input_number" + "input_select" + "input_text" + "integration" + "ios" + "jellyfin" + "light" + "local_calendar" + "local_file" + "local_ip" + "local_todo" + "lock" + "logentries" + "logger" + "lovelace" + "manual" + "manual_mqtt" + "matter" + "media_player" + "min_max" + "mjpeg" + "modern_forms" + "mold_indicator" + "moon" + "mysensors" + "network" + "nmap_tracker" + "notify" + "number" + "onboarding" + "onkyo" + "panel_custom" + "persistent_notification" + "person" + "ping" + "plant" + "prometheus" + "proximity" + "push" + "proximity" + "python_script" + "radio_browser" + "random" + "recorder" + "remote" + "repairs" + "rest" + "rest_command" + "rss_feed_template" + "scene" + "schedule" + "scrape" + "script" + "search" + "season" + "select" + "sense" + "sensor" + "sensorpush" + "shell_command" + "shopping_list" + "siren" + "smtp" + "snmp" + "sql" + "statistics" + "sun" + "switch" + "switch_as_x" + "system_health" + "system_log" + "systemmonitor" + "tag" + "tailscale" + "tcp" + "template" + "text" + "thread" + "threshold" + "time_date" + "timer" + "tod" + "todo" + "tomorrowio" + "trend" + "universal" + "upb" + "update" + "upnp" + "uptime" + "utility_meter" + "vacuum" + "vlc" + "vlc_telnet" + "wake_on_lan" + "water_heater" + "weather" + "websocket_api" + "wled" + "workday" + "worldclock" + "zone" + ]; + + extraPackages = + python3Packages: with python3Packages; [ + onkyo-eiscp + zeroconf + ]; + + customComponents = with pkgs; [ + home-assistant-browser-mod + ]; + + customLovelaceModules = with pkgs.home-assistant-custom-lovelace-modules; [ + bubble-card + button-card + card-mod + light-entity-card + mini-graph-card + mini-media-player + mushroom + sankey-chart + universal-remote-card + ]; + + lovelaceConfigWritable = true; + }; + + modules.services.borgmatic.directories = [ + config.services.home-assistant.configDir + ]; + + services.nginx = { + enable = true; + virtualHosts."home.mesh.vimium.net" = { + forceSSL = false; + extraConfig = '' + proxy_buffering off; + ''; + locations."/" = { + proxyPass = "http://[::1]:8123"; + proxyWebsockets = true; + }; + }; + }; +} diff --git a/modules/nixos/services/home-assistant/floorplan/default.nix b/hosts/pi/home-assistant/floorplan/default.nix similarity index 100% rename from modules/nixos/services/home-assistant/floorplan/default.nix rename to hosts/pi/home-assistant/floorplan/default.nix diff --git a/modules/nixos/services/home-assistant/floorplan/style.css b/hosts/pi/home-assistant/floorplan/style.css similarity index 100% rename from modules/nixos/services/home-assistant/floorplan/style.css rename to hosts/pi/home-assistant/floorplan/style.css diff --git a/modules/nixos/services/home-assistant/mqtt.nix b/hosts/pi/home-assistant/mqtt.nix similarity index 100% rename from modules/nixos/services/home-assistant/mqtt.nix rename to hosts/pi/home-assistant/mqtt.nix diff --git a/modules/nixos/services/home-assistant/default.nix b/modules/nixos/services/home-assistant/default.nix deleted file mode 100644 index d0a6ee8..0000000 --- a/modules/nixos/services/home-assistant/default.nix +++ /dev/null @@ -1,306 +0,0 @@ -{ - config, - lib, - pkgs, - self, - ... -}: - -let - cfg = config.modules.services.home-assistant; -in -{ - imports = [ - ./floorplan/default.nix - ./mqtt.nix - ]; - - options.modules.services.home-assistant.enable = lib.mkEnableOption "home-assistant"; - - config = lib.mkIf cfg.enable { - - age.secrets."files/services/home-assistant/secrets.yaml" = { - file = "${self.inputs.secrets}/files/services/home-assistant/secrets.yaml.age"; - path = "${config.services.home-assistant.configDir}/secrets.yaml"; - owner = "hass"; - group = "hass"; - }; - - services.home-assistant = { - enable = true; - - config = { - automation = "!include automations.yaml"; - backup = { }; - binary_sensor = [ ]; - default_config = { }; - http = { - server_host = "::1"; - trusted_proxies = [ "::1" ]; - use_x_forwarded_for = true; - }; - ffmpeg = { }; - homeassistant = { - name = "Home"; - latitude = "!secret latitude"; - longitude = "!secret longitude"; - country = "GB"; - temperature_unit = "C"; - time_zone = config.time.timeZone; - unit_system = "metric"; - auth_providers = [ - { - type = "trusted_networks"; - trusted_networks = [ - "100.64.0.0/10" - "127.0.0.1" - ]; - allow_bypass_login = true; - } - { - type = "homeassistant"; - } - ]; - }; - logger = { - default = "info"; - logs = { }; - }; - lovelace = { - mode = "yaml"; - }; - media_player = [ ]; - mobile_app = { }; - onkyo = { }; - open_meteo = { }; - recorder = { - purge_keep_days = 365; - }; - scene = "!include scenes.yaml"; - script = "!include scripts.yaml"; - sensor = [ ]; - system_health = { }; - zeroconf = { }; - }; - - extraComponents = [ - "air_quality" - "airly" - "alert" - "api" - "application_credentials" - "asuswrt" - "auth" - "automation" - "bayesian" - "binary_sensor" - # "blackbird" - "blueprint" - "bluetooth_adapters" - "bluetooth_le_tracker" - "button" - "calendar" - "camera" - "cast" - "cert_expiry" - "climate" - "co2signal" - "color_extractor" - "command_line" - "compensation" - "configurator" - "counter" - "cover" - "cpuspeed" - "default_config" - "demo" - "derivative" - "device_automation" - "device_sun_light_trigger" - "device_tracker" - "dlna_dmr" - "dlna_dms" - "dnsip" - "esphome" - "fail2ban" - "fan" - "feedreader" - "ffmpeg" - "file" - "file_upload" - "filesize" - "folder" - "folder_watcher" - "forecast_solar" - "frontend" - "gdacs" - "generic" - "generic_hygrostat" - "generic_thermostat" - "geo_json_events" - "geo_location" - "geo_rss_events" - "github" - "group" - "hardware" - "hdmi_cec" - "history_stats" - "homeassistant" - "homekit" - "homekit_controller" - "html5" - "http" - "humidifier" - "icloud" - "image_processing" - "input_boolean" - "input_button" - "input_datetime" - "input_number" - "input_select" - "input_text" - "integration" - "ios" - "jellyfin" - "light" - "local_calendar" - "local_file" - "local_ip" - "local_todo" - "lock" - "logentries" - "logger" - "lovelace" - "manual" - "manual_mqtt" - "matter" - "media_player" - "min_max" - "mjpeg" - "modern_forms" - "mold_indicator" - "moon" - "mysensors" - "network" - "nmap_tracker" - "notify" - "number" - "onboarding" - "onkyo" - "panel_custom" - "persistent_notification" - "person" - "ping" - "plant" - "prometheus" - "proximity" - "push" - "proximity" - "python_script" - "radio_browser" - "random" - "recorder" - "remote" - "repairs" - "rest" - "rest_command" - "rss_feed_template" - "scene" - "schedule" - "scrape" - "script" - "search" - "season" - "select" - "sense" - "sensor" - "sensorpush" - "shell_command" - "shopping_list" - "siren" - "smtp" - "snmp" - "sql" - "statistics" - "sun" - "switch" - "switch_as_x" - "system_health" - "system_log" - "systemmonitor" - "tag" - "tailscale" - "tcp" - "template" - "text" - "thread" - "threshold" - "time_date" - "timer" - "tod" - "todo" - "tomorrowio" - "trend" - "universal" - "upb" - "update" - "upnp" - "uptime" - "utility_meter" - "vacuum" - "vlc" - "vlc_telnet" - "wake_on_lan" - "water_heater" - "weather" - "websocket_api" - "wled" - "workday" - "worldclock" - "zone" - ]; - - extraPackages = - python3Packages: with python3Packages; [ - onkyo-eiscp - zeroconf - ]; - - customComponents = with pkgs; [ - home-assistant-browser-mod - ]; - - customLovelaceModules = with pkgs.home-assistant-custom-lovelace-modules; [ - bubble-card - button-card - card-mod - light-entity-card - mini-graph-card - mini-media-player - mushroom - sankey-chart - universal-remote-card - ]; - - lovelaceConfigWritable = true; - }; - - modules.services.borgmatic.directories = [ - config.services.home-assistant.configDir - ]; - - services.nginx = { - enable = true; - virtualHosts."home.mesh.vimium.net" = { - forceSSL = false; - extraConfig = '' - proxy_buffering off; - ''; - locations."/" = { - proxyPass = "http://[::1]:8123"; - proxyWebsockets = true; - }; - }; - }; - }; -}