diff --git a/modules/services/home-assistant/default.nix b/modules/services/home-assistant/default.nix new file mode 100644 index 0000000..2d0a1b6 --- /dev/null +++ b/modules/services/home-assistant/default.nix @@ -0,0 +1,32 @@ +{ lib, config, self, ... }: + +let + cfg = config.modules.home-assistant; +in +{ + options.modules.home-assistant.volumes = lib.mkOption { + type = lib.types.listOf lib.types.str; + description = "Volumes to mount (needs /config)"; + }; + + options.modules.home-assistant.addDbusVolume = lib.mkOption { + type = lib.types.bool; + description = "D-Bus is optional but required if you plan to use the Bluetooth integration"; + default = true; + }; + + config = { + virtualisation.oci-containers.containers."homeassistant" = { + volumes = cfg.volumes ++ lib.optionals cfg.addDbusVolume [ "/run/dbus:/run/dbus:ro" ] ++ [ (builtins.toString ./. + ":/patches") ]; + environment.TZ = config.time.timeZone; + image = "ghcr.io/home-assistant/home-assistant:stable"; + extraOptions = [ + "--network=host" + "--pull=newer" + ]; + entrypoint ="/patches/start.sh"; + }; + + networking.firewall.allowedTCPPorts = [ 8123 ]; + }; +} diff --git a/modules/services/home-assistant/start.sh b/modules/services/home-assistant/start.sh new file mode 100755 index 0000000..1cf25d8 --- /dev/null +++ b/modules/services/home-assistant/start.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +pip install py_mini_racer && exec /init