From 89cc4b679ce1f86e50911abfc3ebc5f6d1f94a22 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Mon, 16 Nov 2026 23:53:23 +0000 Subject: [PATCH] nixos/sfh: Start Home Assistant without the webcam An absent webcam made the nspawn bind mount fail before Home Assistant could start. Give the container an always-present directory and bind the video device into it when it is available. Point go2rtc at the device in that directory. --- docs/sites/home/sfh/containers/hass.md | 6 ++++-- .../home/palace/vms/sfh/containers/hass.nix | 2 +- nixos/boxes/home/palace/vms/sfh/default.nix | 18 +++++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/docs/sites/home/sfh/containers/hass.md b/docs/sites/home/sfh/containers/hass.md index 23f1b99..a69a349 100644 --- a/docs/sites/home/sfh/containers/hass.md +++ b/docs/sites/home/sfh/containers/hass.md @@ -18,7 +18,7 @@ integrations. A `hass-cli` wrapper uses a token from `my.secrets` to reach the l - **mosquitto** — MQTT broker (anonymous local listener; port 1883 allowed, alongside HTTP). - **go2rtc** — restreams the Reolink living-room camera (RTSP from `reolink-living-room`, on the - `lo` network) and the office USB webcam (`/dev/video0` via ffmpeg). + `lo` network) and the office USB webcam (`/dev/hass-webcam/video0` via ffmpeg). - **Frigate** (`services.frigate`, `frigate.h.nul.ie` — the `frigate` alt name on the `hi` assignment) — records both restreamed cameras with a short retention policy; detection is disabled. @@ -42,7 +42,9 @@ Frigate footage lives on a **separate HDD LV**: `palace` passes the `hdds/frigat Passed through from `sfh` (USB host ports on `palace`): - Nabu Casa Connect ZBT-1 Zigbee coordinator → `/dev/ttyUSB0` (used by `zha`). -- USB webcam → `/dev/video0` (go2rtc's `webcam_office` stream). +- USB webcam → `/dev/hass-webcam/video0` (go2rtc's `webcam_office` stream). The container + starts with an empty `/dev/hass-webcam` directory if the webcam is absent. Restart the + container after reconnecting the webcam to expose it again. - The matching raw USB device node allowed through from `sfh`. ## Networking diff --git a/nixos/boxes/home/palace/vms/sfh/containers/hass.nix b/nixos/boxes/home/palace/vms/sfh/containers/hass.nix index c9b3564..1a82e2d 100644 --- a/nixos/boxes/home/palace/vms/sfh/containers/hass.nix +++ b/nixos/boxes/home/palace/vms/sfh/containers/hass.nix @@ -113,7 +113,7 @@ in "rtsp://admin:@reolink-living-room:554/h264Preview_01_main" ]; webcam_office = [ - "ffmpeg:device?video=/dev/video0&video_size=1024x576#video=h264" + "ffmpeg:device?video=/dev/hass-webcam/video0&video_size=1024x576#video=h264" ]; }; }; diff --git a/nixos/boxes/home/palace/vms/sfh/default.nix b/nixos/boxes/home/palace/vms/sfh/default.nix index 11c7a92..b703b53 100644 --- a/nixos/boxes/home/palace/vms/sfh/default.nix +++ b/nixos/boxes/home/palace/vms/sfh/default.nix @@ -175,10 +175,15 @@ in }; systemd.services = { - "systemd-nspawn@hass".serviceConfig.DeviceAllow = [ - "char-ttyUSB rw" - "char-video4linux rw" - ]; + "systemd-nspawn@hass".serviceConfig = { + DeviceAllow = [ + "char-ttyUSB rw" + "char-video4linux rw" + ]; + # Pass an empty directory to nspawn when the webcam is absent. + RuntimeDirectory = "hass-webcam"; + BindPaths = [ "-/dev/video0:/run/hass-webcam/video0" ]; + }; # Coding agents; keep the other containers responsive "systemd-nspawn@slop-cannon".serviceConfig = { CPUWeight = 20; @@ -215,7 +220,10 @@ in readOnly = false; }; "/dev/bus/usb/001/002".readOnly = false; - "/dev/video0".readOnly = false; + "/run/hass-webcam" = { + mountPoint = "/dev/hass-webcam"; + readOnly = false; + }; "/dev/serial/by-id/usb-Nabu_Casa_Home_Assistant_Connect_ZBT-1_ce549704fe38ef11a2c2e5d154516304-if00-port0" = { readOnly = false; mountPoint = "/dev/ttyUSB0";