mirror of
https://github.com/RichieCahill/dotfiles.git
synced 2026-04-17 13:08:19 -04:00
moved home_assistant data to postgres
This commit is contained in:
@@ -2,6 +2,14 @@ let
|
|||||||
vars = import ../vars.nix;
|
vars = import ../vars.nix;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
users = {
|
||||||
|
users.hass = {
|
||||||
|
isSystemUser = true;
|
||||||
|
group = "hass";
|
||||||
|
};
|
||||||
|
groups.hass = {};
|
||||||
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
home-assistant = {
|
home-assistant = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -23,6 +31,12 @@ in
|
|||||||
unit_system = "us_customary";
|
unit_system = "us_customary";
|
||||||
temperature_unit = "F";
|
temperature_unit = "F";
|
||||||
};
|
};
|
||||||
|
recorder = {
|
||||||
|
db_url = "postgresql://@/hass";
|
||||||
|
auto_purge = true;
|
||||||
|
purge_keep_days = 3650;
|
||||||
|
db_retry_wait = 15;
|
||||||
|
};
|
||||||
assist_pipeline = { };
|
assist_pipeline = { };
|
||||||
backup = { };
|
backup = { };
|
||||||
bluetooth = { };
|
bluetooth = { };
|
||||||
|
|||||||
@@ -14,15 +14,27 @@ in
|
|||||||
|
|
||||||
authentication = pkgs.lib.mkOverride 10 ''
|
authentication = pkgs.lib.mkOverride 10 ''
|
||||||
|
|
||||||
|
# admins
|
||||||
|
local all postgres trust
|
||||||
|
host all postgres 127.0.0.1/32 trust
|
||||||
|
host all postgres ::1/128 trust
|
||||||
|
|
||||||
|
local all richie trust
|
||||||
|
host all richie 127.0.0.1/32 trust
|
||||||
|
host all richie ::1/128 trust
|
||||||
|
host all richie 192.168.90.1/24 trust
|
||||||
|
host all richie 192.168.95.1/24 trust
|
||||||
|
|
||||||
|
|
||||||
#type database DBuser origin-address auth-method
|
#type database DBuser origin-address auth-method
|
||||||
local all all trust
|
local hass hass trust
|
||||||
|
|
||||||
# ipv4
|
# ipv4
|
||||||
host all all 127.0.0.1/32 trust
|
host hass hass 192.168.90.1/24 trust
|
||||||
host all all 192.168.90.1/24 trust
|
host hass hass 127.0.0.1/32 trust
|
||||||
|
|
||||||
# ipv6
|
# ipv6
|
||||||
host all all ::1/128 trust
|
host hass hass ::1/128 trust
|
||||||
'';
|
'';
|
||||||
|
|
||||||
identMap = ''
|
identMap = ''
|
||||||
@@ -31,6 +43,7 @@ in
|
|||||||
superuser_map postgres postgres
|
superuser_map postgres postgres
|
||||||
# Let other names login as themselves
|
# Let other names login as themselves
|
||||||
superuser_map richie postgres
|
superuser_map richie postgres
|
||||||
|
superuser_map hass hass
|
||||||
'';
|
'';
|
||||||
ensureUsers = [
|
ensureUsers = [
|
||||||
{
|
{
|
||||||
@@ -45,6 +58,7 @@ in
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "richie";
|
name = "richie";
|
||||||
|
ensureDBOwnership = true;
|
||||||
ensureClauses = {
|
ensureClauses = {
|
||||||
superuser = true;
|
superuser = true;
|
||||||
login = true;
|
login = true;
|
||||||
@@ -53,6 +67,22 @@ in
|
|||||||
replication = true;
|
replication = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
name = "hass";
|
||||||
|
ensureDBOwnership = true;
|
||||||
|
ensureClauses = {
|
||||||
|
login = true;
|
||||||
|
createrole = true;
|
||||||
|
createdb = true;
|
||||||
|
replication = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
ensureDatabases = [
|
||||||
|
"hass"
|
||||||
|
"mxr_dev"
|
||||||
|
"mxr_prod"
|
||||||
|
"richie"
|
||||||
];
|
];
|
||||||
# Thank you NotAShelf
|
# Thank you NotAShelf
|
||||||
# https://github.com/NotAShelf/nyx/blob/d407b4d6e5ab7f60350af61a3d73a62a5e9ac660/modules/core/roles/server/system/services/databases/postgresql.nix#L74
|
# https://github.com/NotAShelf/nyx/blob/d407b4d6e5ab7f60350af61a3d73a62a5e9ac660/modules/core/roles/server/system/services/databases/postgresql.nix#L74
|
||||||
|
|||||||
Reference in New Issue
Block a user