62 lines
1.8 KiB
Nix
62 lines
1.8 KiB
Nix
{ config, lib, ... }: let
|
|
|
|
hostPort = 9003;
|
|
|
|
subdomain = "hass";
|
|
|
|
name = "home-assistant";
|
|
|
|
in {
|
|
|
|
options.sysconfig.docker.home-assistant.enable = with lib; mkOption {
|
|
type = with types; bool;
|
|
default = false;
|
|
};
|
|
|
|
config = lib.mkIf (config.sysconfig.docker.home-assistant.enable && config.sysconfig.docker.enable) {
|
|
|
|
networking.firewall.interfaces = {
|
|
"ve-traefik" = {
|
|
allowedTCPPorts = [ hostPort ];
|
|
};
|
|
};
|
|
|
|
environment.etc."home-assistant/configuration.yaml".source = ./configuration.yaml;
|
|
|
|
virtualisation.oci-containers.containers.home-assistant = {
|
|
image = "ghcr.io/home-assistant/home-assistant:stable";
|
|
|
|
# unstable, waiting for 26.05
|
|
#pull = "newer";
|
|
|
|
hostname = "${subdomain}.esotericbytes.com";
|
|
|
|
networks = [
|
|
"docker-main"
|
|
];
|
|
|
|
labels = {
|
|
"traefik.http.routers.${name}.entrypoints" = "localsecure";
|
|
"traefik.http.routers.${name}.rule" = "Host(`${subdomain}.esotericbytes.com`)";
|
|
"traefik.http.routers.${name}.service" = "${name}";
|
|
"traefik.http.routers.${name}.tls.certResolver" = "cloudflare";
|
|
|
|
"traefik.http.services.${name}.loadbalancer.server.url" = "http://192.168.100.10:${builtins.toString hostPort}";
|
|
};
|
|
|
|
environment = {
|
|
TZ = "America/Chicago";
|
|
};
|
|
|
|
ports = [
|
|
"${builtins.toString hostPort}:8123"
|
|
];
|
|
|
|
volumes = [
|
|
"vol_home-assistant:/config/"
|
|
"/etc/home-assistant/configuration.yaml:/config/configuration.yaml"
|
|
];
|
|
};
|
|
};
|
|
}
|