home-automation: use oci container for home-assistant
2 files changed, 32 insertions(+), 39 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} ''; }; };
M system/roles/oci.nix → system/roles/oci.nix
@@ -8,7 +8,7 @@ autoPrune = { enable = true; }; defaultNetwork.settings = { - dns_enabled = true; + dns_enabled = false; }; };@@ -16,7 +16,7 @@ assertions = [ { assertion = (config.virtualisation.podman.defaultNetwork.settings.dns_enabled && config.services.dnsmasq.enable) - && config.services.dnsmasq.settings.bind-interfaces != true; + -> config.services.dnsmasq.settings.bind-interfaces != true; message = "Need to use bind-interfaces in dnsmasq when using dns in a podman network"; } ];