drafted out virt home assistant
This commit is contained in:
parent
ba5d5a1487
commit
77f1aa30b7
4 changed files with 270 additions and 75 deletions
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
configDir = "/var/lib/hass";
|
||||
|
@ -16,81 +17,114 @@ in {
|
|||
|
||||
config = lib.mkIf config.host.home-assistant.enable (lib.mkMerge [
|
||||
{
|
||||
systemd.tmpfiles.rules = [
|
||||
"f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass"
|
||||
];
|
||||
services.home-assistant = {
|
||||
enable = true;
|
||||
configDir = configDir;
|
||||
extraComponents = [
|
||||
"met"
|
||||
"radio_browser"
|
||||
"isal"
|
||||
"zha"
|
||||
"jellyfin"
|
||||
"webostv"
|
||||
"tailscale"
|
||||
"syncthing"
|
||||
"sonos"
|
||||
"analytics_insights"
|
||||
"unifi"
|
||||
"openweathermap"
|
||||
];
|
||||
config = {
|
||||
http = {
|
||||
server_port = 8082;
|
||||
use_x_forwarded_for = true;
|
||||
trusted_proxies = ["127.0.0.1" "::1"];
|
||||
ip_ban_enabled = true;
|
||||
login_attempts_threshold = 10;
|
||||
};
|
||||
# recorder.db_url = "postgresql://@/${db_user}";
|
||||
"automation manual" = [];
|
||||
"automation ui" = "!include automations.yaml";
|
||||
};
|
||||
extraPackages = python3Packages:
|
||||
with python3Packages; [
|
||||
hassil
|
||||
numpy
|
||||
gtts
|
||||
virtualisation.libvirt = {
|
||||
swtpm.enable = true;
|
||||
connections."qemu:///session" = {
|
||||
networks = [
|
||||
{
|
||||
definition = inputs.nix-virt.lib.network.writeXML (inputs.nix-virt.lib.network.templates.bridge
|
||||
{
|
||||
uuid = "d57e37e2-311f-4e5c-a484-97c2210c2770";
|
||||
subnet_byte = 71;
|
||||
});
|
||||
active = true;
|
||||
}
|
||||
];
|
||||
domains = [
|
||||
{
|
||||
definition = inputs.nix-virt.lib.domain.writeXML (inputs.nix-virt.lib.domain.templates.linux
|
||||
{
|
||||
name = "Home Assistant";
|
||||
uuid = "c5cc0efc-6101-4c1d-be31-acbba203ccde";
|
||||
memory = {
|
||||
count = 4;
|
||||
unit = "GiB";
|
||||
};
|
||||
# storage_vol = {
|
||||
# pool = "MyPool";
|
||||
# volume = "Penguin.qcow2";
|
||||
# };
|
||||
});
|
||||
}
|
||||
];
|
||||
};
|
||||
host = {
|
||||
reverse_proxy.subdomains.${config.host.home-assistant.subdomain} = {
|
||||
target = "http://localhost:${toString config.services.home-assistant.config.http.server_port}";
|
||||
|
||||
websockets.enable = true;
|
||||
forwardHeaders.enable = true;
|
||||
|
||||
extraConfig = ''
|
||||
add_header Upgrade $http_upgrade;
|
||||
add_header Connection \"upgrade\";
|
||||
|
||||
proxy_buffering off;
|
||||
|
||||
proxy_read_timeout 90;
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# systemd.tmpfiles.rules = [
|
||||
# "f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass"
|
||||
# ];
|
||||
# services.home-assistant = {
|
||||
# enable = true;
|
||||
# configDir = configDir;
|
||||
# extraComponents = [
|
||||
# "met"
|
||||
# "radio_browser"
|
||||
# "isal"
|
||||
# "zha"
|
||||
# "jellyfin"
|
||||
# "webostv"
|
||||
# "tailscale"
|
||||
# "syncthing"
|
||||
# "sonos"
|
||||
# "analytics_insights"
|
||||
# "unifi"
|
||||
# "openweathermap"
|
||||
# ];
|
||||
# config = {
|
||||
# http = {
|
||||
# server_port = 8082;
|
||||
# use_x_forwarded_for = true;
|
||||
# trusted_proxies = ["127.0.0.1" "::1"];
|
||||
# ip_ban_enabled = true;
|
||||
# login_attempts_threshold = 10;
|
||||
# };
|
||||
# # recorder.db_url = "postgresql://@/${db_user}";
|
||||
# "automation manual" = [];
|
||||
# "automation ui" = "!include automations.yaml";
|
||||
# };
|
||||
# extraPackages = python3Packages:
|
||||
# with python3Packages; [
|
||||
# hassil
|
||||
# numpy
|
||||
# gtts
|
||||
# ];
|
||||
# };
|
||||
# host = {
|
||||
# reverse_proxy.subdomains.${config.host.home-assistant.subdomain} = {
|
||||
# target = "http://localhost:${toString config.services.home-assistant.config.http.server_port}";
|
||||
|
||||
# websockets.enable = true;
|
||||
# forwardHeaders.enable = true;
|
||||
|
||||
# extraConfig = ''
|
||||
# add_header Upgrade $http_upgrade;
|
||||
# add_header Connection \"upgrade\";
|
||||
|
||||
# proxy_buffering off;
|
||||
|
||||
# proxy_read_timeout 90;
|
||||
# '';
|
||||
# };
|
||||
# };
|
||||
}
|
||||
(lib.mkIf config.host.impermanence.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.services.home-assistant.configDir == configDir;
|
||||
message = "home assistant config directory does not match persistence";
|
||||
}
|
||||
];
|
||||
environment.persistence."/persist/system/root" = {
|
||||
enable = true;
|
||||
hideMounts = true;
|
||||
directories = [
|
||||
{
|
||||
directory = configDir;
|
||||
user = "hass";
|
||||
group = "hass";
|
||||
}
|
||||
];
|
||||
};
|
||||
# assertions = [
|
||||
# {
|
||||
# assertion = config.services.home-assistant.configDir == configDir;
|
||||
# message = "home assistant config directory does not match persistence";
|
||||
# }
|
||||
# ];
|
||||
# environment.persistence."/persist/system/root" = {
|
||||
# enable = true;
|
||||
# hideMounts = true;
|
||||
# directories = [
|
||||
# {
|
||||
# directory = configDir;
|
||||
# user = "hass";
|
||||
# group = "hass";
|
||||
# }
|
||||
# ];
|
||||
# };
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue