72 lines
1.9 KiB
Nix
72 lines
1.9 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
homeAssistantVersion = "2026.2.3";
|
|
mqttVersion = "2.1-alpine";
|
|
helper = import ./lib.nix { inherit config pkgs lib; };
|
|
cfg = config.numbus.services.home-assistant;
|
|
in
|
|
|
|
helper.mkPodmanService {
|
|
description = "Home Assistant, libre house control and much more";
|
|
name = "home-assistant";
|
|
pod = "home-assistant";
|
|
defaultPort = "8123";
|
|
dataDir = false;
|
|
|
|
extraOptions = {
|
|
devices = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [];
|
|
example = [ "/dev/serial/by-id/Sonoff_Zigbee_3.0-id-port0:/dev/ttyUSB0" ];
|
|
description = "List of devices to map into the container. /dev/ttyUSB0 is used for Zigbee dongles";
|
|
};
|
|
};
|
|
|
|
# Compose file good
|
|
composeText = ''
|
|
services:
|
|
home-assistant:
|
|
image: ghcr.io/home-assistant/home-assistant:${homeAssistantVersion}
|
|
container_name: home-assistant
|
|
hostname: home-assistant
|
|
networks:
|
|
home-assistant:
|
|
ports:
|
|
- "${cfg.port}:8123/tcp"
|
|
volumes:
|
|
- ${cfg.configDir}/config:/config
|
|
- /etc/localtime:/etc/localtime:ro
|
|
- /run/dbus:/run/dbus:ro
|
|
${lib.optionalString (cfg.devices != []) ''
|
|
devices:
|
|
${lib.concatStringsSep "\n" (map (d: " - \"${d}\"") cfg.devices)}
|
|
''}
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
cap_drop:
|
|
- NET_RAW
|
|
restart: unless-stopped
|
|
home-assistant-mqtt:
|
|
image: docker.io/library/eclipse-mosquitto:${mqttVersion}
|
|
container_name: home-assistant-mqtt
|
|
hostname: home-assistant-mqtt
|
|
user: '1000:1000'
|
|
networks:
|
|
home-assistant:
|
|
volumes:
|
|
- ${cfg.configDir}/mqtt:/mosquitto
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
cap_drop:
|
|
- NET_RAW
|
|
restart: unless-stopped
|
|
networks:
|
|
home-assistant:
|
|
name: home-assistant
|
|
driver: bridge
|
|
'';
|
|
}
|