2022-01-18 00:23:43 +01:00
|
|
|
{ nglib, nixpkgs }:
|
2022-10-25 18:34:25 +02:00
|
|
|
{
|
|
|
|
postgresql = nglib.makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "nixng-hass-postgresql";
|
|
|
|
inherit nixpkgs;
|
|
|
|
config = { pkgs, config, ... }:
|
2022-01-18 00:23:43 +01:00
|
|
|
{
|
|
|
|
config = {
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
2022-10-25 18:34:25 +02:00
|
|
|
type.services = {};
|
2022-01-18 00:23:43 +01:00
|
|
|
};
|
2022-10-25 18:34:25 +02:00
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.postgresql_12;
|
|
|
|
|
|
|
|
initialScript = "/secrets/init.sql";
|
|
|
|
enableTCPIP = true;
|
|
|
|
|
|
|
|
authentication = "host all all all md5";
|
2022-01-18 00:23:43 +01:00
|
|
|
|
2022-10-25 18:34:25 +02:00
|
|
|
ensureDatabases = [ "hass" ];
|
|
|
|
ensureExtensions = {
|
|
|
|
"pg_trgm" = [ "hass" ];
|
2022-10-10 17:48:19 +02:00
|
|
|
};
|
2022-10-25 18:34:25 +02:00
|
|
|
ensureUsers = [
|
|
|
|
{ name = "hass"; ensurePermissions = {
|
|
|
|
"DATABASE \"hass\"" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2022-01-18 00:23:43 +01:00
|
|
|
};
|
2022-10-25 18:34:25 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
hass =
|
|
|
|
nglib.makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "nixng-home-assistant";
|
|
|
|
inherit nixpkgs;
|
|
|
|
config = ({ pkgs, config, nglib, ... }:
|
|
|
|
let
|
|
|
|
ids = config.ids;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = {
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
type.services = { };
|
|
|
|
};
|
2022-01-18 00:23:43 +01:00
|
|
|
|
2022-10-25 18:34:25 +02:00
|
|
|
init.services.home-assistant = {
|
|
|
|
shutdownOnExit = true;
|
|
|
|
environment = {
|
|
|
|
PATH = with pkgs; pkgs.lib.makeBinPath [
|
|
|
|
coreutils git ffmpeg bash runit
|
|
|
|
];
|
2022-03-23 10:36:59 +01:00
|
|
|
};
|
2022-01-18 00:23:43 +01:00
|
|
|
};
|
2022-10-25 18:34:25 +02:00
|
|
|
|
|
|
|
services.home-assistant = {
|
|
|
|
enable = true;
|
|
|
|
envsubst = true;
|
|
|
|
customComponents = {};
|
|
|
|
config =
|
|
|
|
{ default_config = {};
|
|
|
|
recorder = {
|
|
|
|
db_url = "postgresql://hass:\${PSQL_PASSWORD}@127.0.0.1/hass";
|
|
|
|
db_max_retries = 5;
|
|
|
|
db_retry_wait = 30;
|
|
|
|
};
|
|
|
|
stream = {};
|
|
|
|
http = {
|
|
|
|
server_port = "8123";
|
|
|
|
use_x_forwarded_for = true;
|
|
|
|
trusted_proxies = [ "127.0.0.1" ];
|
|
|
|
};
|
|
|
|
logger.default = "info";
|
|
|
|
homeassistant =
|
|
|
|
{ name = "Home";
|
|
|
|
latitude = "\${LATITUDE}";
|
|
|
|
longitude = "\${LONGTITUDE}";
|
|
|
|
elevation = "\${ELEVATION}";
|
|
|
|
# currency = "EUR";
|
|
|
|
unit_system = "metric";
|
|
|
|
time_zone = "\${TIME_ZONE}";
|
|
|
|
internal_url = "http://localhost:8123/";
|
|
|
|
};
|
|
|
|
automation = "!include automations.yaml";
|
|
|
|
"automation static" = [
|
|
|
|
(import ./home-assistant/automations/alarm/pending.nix)
|
|
|
|
(import ./home-assistant/automations/alarm/disarmed.nix)
|
|
|
|
(import ./home-assistant/automations/alarm/triggered.nix)
|
|
|
|
(import ./home-assistant/automations/alarm/motion-detected.nix)
|
|
|
|
(import ./home-assistant/automations/alarm/motion-detected-away.nix)
|
2022-01-18 00:23:43 +01:00
|
|
|
];
|
2022-10-25 18:34:25 +02:00
|
|
|
alarm_control_panel = import ./home-assistant/alarm_control_panel.nix;
|
|
|
|
frontend.themes =
|
|
|
|
{ };
|
|
|
|
};
|
|
|
|
package =
|
|
|
|
(pkgs.home-assistant.override
|
|
|
|
{ extraComponents =
|
|
|
|
[ "http"
|
|
|
|
"homeassistant"
|
|
|
|
"image"
|
|
|
|
"person"
|
|
|
|
"cloud"
|
|
|
|
"onboarding"
|
|
|
|
"frontend"
|
|
|
|
"safe_mode"
|
|
|
|
"met"
|
|
|
|
"zha"
|
|
|
|
"mobile_app"
|
|
|
|
"dhcp"
|
|
|
|
"logbook"
|
|
|
|
"history"
|
|
|
|
"ssdp"
|
|
|
|
"mqtt"
|
|
|
|
"stream"
|
|
|
|
"recorder"
|
|
|
|
];
|
|
|
|
extraPackages = ps: with ps;
|
|
|
|
[ xmodem
|
|
|
|
psycopg2
|
|
|
|
];
|
|
|
|
}).overridePythonAttrs (old:
|
|
|
|
{ doCheck = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-01-18 00:23:43 +01:00
|
|
|
}
|