2025-01-04 23:25:48 +01:00
|
|
|
{
|
|
|
|
config,
|
2025-01-07 21:23:06 +01:00
|
|
|
globals,
|
2025-01-04 23:25:48 +01:00
|
|
|
nodes,
|
2025-01-05 22:27:49 +01:00
|
|
|
lib,
|
2025-01-09 13:58:51 +01:00
|
|
|
pkgs,
|
2025-01-04 23:25:48 +01:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
environment.persistence."/persist".directories = [
|
2025-01-09 13:58:51 +01:00
|
|
|
{
|
|
|
|
directory = "/var/lib/private/esphome";
|
|
|
|
mode = "0700";
|
|
|
|
}
|
2025-01-04 23:25:48 +01:00
|
|
|
{
|
|
|
|
directory = config.services.home-assistant.configDir;
|
|
|
|
user = "hass";
|
|
|
|
group = "hass";
|
|
|
|
mode = "0700";
|
|
|
|
}
|
|
|
|
];
|
2025-01-09 13:58:51 +01:00
|
|
|
|
|
|
|
services.esphome = {
|
|
|
|
enable = true;
|
|
|
|
address = "0.0.0.0";
|
|
|
|
port = 3001;
|
|
|
|
#allowedDevices = lib.mkForce ["/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0"];
|
|
|
|
# TODO instead deny the zigbee device
|
|
|
|
};
|
|
|
|
|
2025-01-04 23:25:48 +01:00
|
|
|
wireguard.services = {
|
|
|
|
client.via = "nucnix";
|
2025-01-09 13:58:51 +01:00
|
|
|
firewallRuleForNode.${globals.services.nginx.host}.allowedTCPPorts = [
|
|
|
|
3000
|
|
|
|
3001
|
|
|
|
];
|
2025-01-04 23:25:48 +01:00
|
|
|
};
|
|
|
|
services.home-assistant = {
|
|
|
|
enable = true;
|
|
|
|
extraComponents = [
|
|
|
|
"radio_browser"
|
|
|
|
"met"
|
|
|
|
"esphome"
|
|
|
|
"fritzbox"
|
2025-01-07 21:23:06 +01:00
|
|
|
"homematic"
|
2025-01-04 23:25:48 +01:00
|
|
|
"soundtouch"
|
|
|
|
"spotify"
|
|
|
|
"matter"
|
2025-01-07 21:23:06 +01:00
|
|
|
"esphome"
|
2025-01-04 23:25:48 +01:00
|
|
|
#"zha"
|
|
|
|
"mqtt"
|
2025-01-08 17:46:44 +01:00
|
|
|
"ollama"
|
2025-01-09 13:58:51 +01:00
|
|
|
"solaredge"
|
|
|
|
];
|
|
|
|
customComponents = with pkgs.home-assistant-custom-components; [
|
|
|
|
homematicip_local
|
|
|
|
pkgs.havartastorage
|
2025-01-04 23:25:48 +01:00
|
|
|
];
|
|
|
|
config = {
|
|
|
|
http = {
|
|
|
|
server_host = [ "0.0.0.0" ];
|
|
|
|
server_port = 3000;
|
|
|
|
use_x_forwarded_for = true;
|
|
|
|
trusted_proxies = [ nodes.nucnix-nginx.config.wireguard.services.ipv4 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
homeassistant = {
|
|
|
|
name = "!secret ha_name";
|
|
|
|
latitude = "!secret ha_latitude";
|
|
|
|
longitude = "!secret ha_longitude";
|
|
|
|
elevation = "!secret ha_elevation";
|
|
|
|
currency = "EUR";
|
|
|
|
time_zone = "Europe/Berlin";
|
|
|
|
unit_system = "metric";
|
|
|
|
#external_url = "https://";
|
|
|
|
packages = {
|
|
|
|
manual = "!include manual.yaml";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
default_config = { };
|
|
|
|
### Components not from default_config
|
|
|
|
|
|
|
|
frontend = {
|
|
|
|
#themes = "!include_dir_merge_named themes";
|
|
|
|
};
|
|
|
|
|
2025-01-05 22:27:49 +01:00
|
|
|
# influxdb = {
|
|
|
|
# api_version = 2;
|
|
|
|
# host = globals.services.influxdb.domain;
|
|
|
|
# port = "443";
|
|
|
|
# max_retries = 10;
|
|
|
|
# ssl = true;
|
|
|
|
# verify_ssl = true;
|
|
|
|
# token = "!secret influxdb_token";
|
|
|
|
# organization = "home";
|
|
|
|
# bucket = "home_assistant";
|
|
|
|
# };
|
2025-01-04 23:25:48 +01:00
|
|
|
};
|
|
|
|
extraPackages =
|
|
|
|
python3Packages: with python3Packages; [
|
|
|
|
psycopg2
|
|
|
|
gtts
|
2025-01-07 21:23:06 +01:00
|
|
|
fritzconnection
|
|
|
|
adguardhome
|
2025-01-09 13:58:51 +01:00
|
|
|
aiosolaredge
|
|
|
|
zlib-ng
|
|
|
|
stringcase
|
|
|
|
hahomematic
|
|
|
|
pymodbus
|
2025-01-04 23:25:48 +01:00
|
|
|
];
|
|
|
|
};
|
2025-01-07 21:23:06 +01:00
|
|
|
networking.hosts = {
|
|
|
|
"${nodes.${globals.services.adguardhome.host}.config.wireguard.services.ipv4}" = [
|
|
|
|
"adguardhome.internal"
|
|
|
|
];
|
2025-01-08 17:46:44 +01:00
|
|
|
"${nodes.${globals.services.ollama.host}.config.wireguard.services.ipv4}" = [
|
|
|
|
"ollama.internal"
|
|
|
|
];
|
2025-01-07 21:23:06 +01:00
|
|
|
};
|
2025-01-05 22:27:49 +01:00
|
|
|
age.secrets."home-assistant-secrets.yaml" = {
|
2025-01-09 13:58:51 +01:00
|
|
|
rekeyFile = config.node.secretsDir + "/secrets.yaml.age";
|
2025-01-05 22:27:49 +01:00
|
|
|
owner = "hass";
|
|
|
|
};
|
|
|
|
systemd.services.home-assistant = {
|
2025-01-06 19:57:05 +01:00
|
|
|
# Update influxdb token
|
|
|
|
# We don't use -i because it would require chown with is a @privileged syscall
|
|
|
|
# INFLUXDB_TOKEN="$(cat ${config.age.secrets.hass-influxdb-token.path})" \
|
|
|
|
# ${lib.getExe pkgs.yq-go} '.influxdb_token = strenv(INFLUXDB_TOKEN)'
|
2025-01-05 22:27:49 +01:00
|
|
|
preStart = lib.mkBefore ''
|
|
|
|
if [[ -e ${config.services.home-assistant.configDir}/secrets.yaml ]]; then
|
|
|
|
rm ${config.services.home-assistant.configDir}/secrets.yaml
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat ${
|
|
|
|
config.age.secrets."home-assistant-secrets.yaml".path
|
|
|
|
} > ${config.services.home-assistant.configDir}/secrets.yaml
|
|
|
|
|
|
|
|
touch -a ${config.services.home-assistant.configDir}/{automations,scenes,scripts,manual}.yaml
|
|
|
|
'';
|
|
|
|
};
|
2025-01-04 23:25:48 +01:00
|
|
|
}
|