home-automation: use oci container for home-assistant
1 file changed, 30 insertions(+), 37 deletions(-)
changed files
M system/roles/home-automation.nix → system/roles/home-automation.nix
@@ -4,51 +4,44 @@ ... }: let inherit (config.networking) hostName domain; + + image = "ghcr.io/home-assistant/home-assistant"; + tag = "stable"; + + port = 8123; + hostPort = "[::1]:${builtins.toString port}"; in { imports = [ - ./postgresql.nix + ./oci.nix ]; - services.home-assistant = { - enable = true; - extraPackages = ps: with ps; [ psycopg2 ]; - extraComponents = [ - ## Components required to complete the onboarding - ## Keep in case of new setup - # "analytics" - # "google_translate" - # "met" - # "radio_browser" - "shopping_list" + virtualisation.oci-containers.containers = { + home-assistant = { + image = "${image}:${tag}"; + autoStart = true; - # Recommended for fast zlib compression - # https://www.home-assistant.io/integrations/isal - "isal" - ]; - config = { - default_config = { }; - recorder.db_url = "postgresql://@/hass"; - http = { - server_host = "::1"; - use_x_forwarded_for = true; - trusted_proxies = "::1"; + environment = { + TZ = config.time.timeZone; }; + volumes = [ + "/var/lib/home-assistant:/config" + ]; + extraOptions = [ + "--network=host" + ]; }; - }; + matter-server = { + image = "ghcr.io/matter-js/python-matter-server:stable"; + autoStart = true; - services.matter-server = { - enable = true; - }; - - services.postgresql = { - ensureDatabases = [ "hass" ]; - ensureUsers = [ - { - name = "hass"; - ensureDBOwnership = true; - } - ]; + volumes = [ + "matter-server:/data" + ]; + extraOptions = [ + "--network=host" + ]; + }; }; services.caddy.virtualHosts = {@@ -59,7 +52,7 @@ issuer internal { ca home } } - reverse_proxy http://[::1]:8123 + reverse_proxy http://${hostPort} ''; }; };