diff --git a/hosts/homeserver/configuration.nix b/hosts/homeserver/configuration.nix --- a/hosts/homeserver/configuration.nix +++ b/hosts/homeserver/configuration.nix @@ -8,6 +8,7 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + ./services/homeassistant.nix ]; # Bootloader. @@ -97,9 +98,11 @@ # Open ports in the firewall. # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ 5353 1900 ]; # Or disable the firewall altogether. - # networking.firewall.enable = false; + + # Be carefull - home asssistent needs weird ports + networking.firewall.enable = false; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/hosts/homeserver/services/homeassistant.nix b/hosts/homeserver/services/homeassistant.nix new file mode 100644 --- /dev/null +++ b/hosts/homeserver/services/homeassistant.nix @@ -0,0 +1,41 @@ +{ + virtualisation.oci-containers = { + backend = "docker"; + + containers = { + homeassistant = { + image = "ghcr.io/home-assistant/home-assistant:stable"; + + volumes = [ + "/srv/apps/homeassistant/config:/config" + "/etc/localtime:/etc/localtime:ro" + "/run/dbus:/run/dbus:ro" + ]; + + extraOptions = [ + "--network=host" + "--privileged" + ]; + + autoStart = true; + }; + + mosquitto = { + image = "docker.io/eclipse-mosquitto:2"; + + volumes = [ + "/srv/apps/mosquitto/config:/mosquitto/config" + "/srv/apps/mosquitto/data:/mosquitto/data" + "/srv/apps/mosquitto/log:/mosquitto/log" + ]; + + ports = [ + "1883:1883" + "9001:9001" + ]; + + autoStart = true; + }; + }; + }; +}