nixos-configs/devices/homie/modules/home-assistant.nix

114 lines
2.6 KiB
Nix
Raw Normal View History

2024-09-01 19:19:30 -04:00
{
config,
lib,
2024-09-02 22:14:49 -04:00
pkgs,
2024-09-01 19:19:30 -04:00
self,
wakewords-src,
2024-09-04 12:20:27 -04:00
dracul-ha-src,
2024-09-01 19:19:30 -04:00
...
}: {
imports = [self.nixosModules.wyoming-plus];
# TODO: some components / integrations / addons require manual interaction in the GUI, find way to make it all declarative
2024-09-01 19:19:30 -04:00
services = {
home-assistant = {
enable = true;
extraComponents = [
"caldav"
2024-09-01 19:19:30 -04:00
"esphome"
"holiday"
"isal"
2024-09-01 19:19:30 -04:00
"met"
2024-09-02 22:14:49 -04:00
"ollama"
2024-09-01 19:19:30 -04:00
"spotify"
"upnp"
"wyoming"
"yamaha_musiccast"
];
2024-09-02 22:14:49 -04:00
customComponents = builtins.attrValues {
inherit (self.legacyPackages.${pkgs.system}.hass-components) home-llm;
2024-09-02 22:14:49 -04:00
};
2024-09-01 19:19:30 -04:00
config = {
# Proxy settings
2024-09-01 19:19:30 -04:00
http = {
server_host = "0.0.0.0";
trusted_proxies = ["100.64.0.8" "100.64.0.9"];
use_x_forwarded_for = true;
};
# Extra conf that was needed
media_source = {};
# GUI
2024-09-04 12:20:27 -04:00
frontend = {
themes = "!include ${dracul-ha-src}/themes/dracul-ha.yaml";
};
lovelace = {
mode = "yaml";
};
# `default_config` enables too much stuff. this is what I want from it
2024-09-01 19:19:30 -04:00
assist_pipeline = {};
config = {};
conversation = {};
dhcp = {};
history = {};
image_upload = {};
logbook = {};
mobile_app = {};
my = {};
sun = {};
automation = {};
zeroconf = {};
};
};
wyoming = {
piper.servers."en" = {
enable = true;
uri = "tcp://127.0.0.1:10200";
# see https://github.com/rhasspy/rhasspy3/blob/master/programs/tts/piper/script/download.py
voice = "en-us-ryan-low"; # using `hfc male (medium)` in GUI
2024-09-01 19:19:30 -04:00
speaker = 0;
};
openwakeword-docker = {
enable = true;
uri = "127.0.0.1:10400";
customModelsDirectories = ["${wakewords-src}/en/yo_homie"];
preloadModels = ["yo_homie"];
};
};
};
services.esphome = {
enable = true;
address = "100.64.0.10";
port = 6052;
};
# FIXME: https://github.com/NixOS/nixpkgs/issues/339557
systemd.services.esphome = let
inherit (lib) mkForce;
cfg = config.services.esphome;
stateDir = "/var/lib/private/esphome";
esphomeParams =
if cfg.enableUnixSocket
then "--socket /run/esphome/esphome.sock"
else "--address ${cfg.address} --port ${toString cfg.port}";
in {
environment.PLATFORMIO_CORE_DIR = mkForce "${stateDir}/.platformio";
serviceConfig = {
ExecStart = mkForce "${cfg.package}/bin/esphome dashboard ${esphomeParams} ${stateDir}";
WorkingDirectory = mkForce stateDir;
};
};
2024-09-01 19:19:30 -04:00
}