Monitoring + home assistant

This commit is contained in:
Aleksandr Lebedev 2025-09-29 19:54:51 +02:00
parent ebdfe095d8
commit 4b6fc29c91
4 changed files with 101 additions and 2 deletions

View file

@ -23,12 +23,10 @@ in {
config = mkIf cfg.enable {
home.packages = with pkgs; [
nextcloud-client
nextcloud-talk-desktop
];
home.persistence = mkIf impermanence.enable {
"${impermanence.persistentStorage}".directories = [
".config/Nextcloud"
".config/Nextcloud Talk"
];
};
};

View file

@ -0,0 +1,47 @@
{
pkgs,
lib,
config,
...
}: {
services.home-assistant = {
enable = true;
extraComponents = [
# Components required to complete the onboarding
"esphome"
"met"
"radio_browser"
"wiz"
];
config = {
http = {
server_host = "::1";
trusted_proxies = ["::1"];
use_x_forwarded_for = true;
};
recorder.db_url = "postgresql://@/hass";
# Includes dependencies for a basic setup
# https://www.home-assistant.io/integrations/default_config/
default_config = {};
};
};
services.home-assistant = {
package =
(pkgs.home-assistant.override {
extraPackages = py: with py; [psycopg2];
}).overrideAttrs (oldAttrs: {
doInstallCheck = false;
});
};
services.postgresql = {
enable = true;
ensureDatabases = ["hass"];
ensureUsers = [
{
name = "hass";
ensureDBOwnership = true;
}
];
};
}

View file

@ -0,0 +1,35 @@
{
pkgs,
lib,
config,
...
}:
# https://dataswamp.org/~solene/2022-09-11-exploring-monitoring-stacks.html
{
services.grafana = {
enable = true;
settings = {
server = {
http_addr = "127.0.0.1";
http_port = 3000;
# Grafana needs to know on which domain and URL it's running
domain = "kylekrein.com";
root_url = "https://grafana.kylekrein.com/";
serve_from_sub_path = false;
};
};
};
services.prometheus.exporters.node.enable = true;
services.prometheus = {
enable = true;
scrapeConfigs = [
{
job_name = "stargate";
static_configs = [
{targets = ["127.0.0.1:9100"];}
];
}
];
};
}

View file

@ -80,6 +80,25 @@ in {
proxyWebsockets = true;
};
};
"smart-home.kylekrein.com" = {
forceSSL = true;
enableACME = true;
extraConfig = ''
proxy_buffering off;
'';
locations."/" = {
proxyPass = "http://[::1]:8123";
proxyWebsockets = true;
};
};
"grafana.kylekrein.com" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}";
proxyWebsockets = true;
};
};
"paperless.kylekrein.com" = {
enableACME = true;
forceSSL = true;