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.
This commit is contained in:
2026-11-18 22:01:54 +00:00
parent 4307939aab
commit 89cc4b679c
3 changed files with 18 additions and 8 deletions
+4 -2
View File
@@ -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). - **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 - **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` - **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 assignment) — records both restreamed cameras with a short retention policy; detection is
disabled. 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`): Passed through from `sfh` (USB host ports on `palace`):
- Nabu Casa Connect ZBT-1 Zigbee coordinator → `/dev/ttyUSB0` (used by `zha`). - 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`. - The matching raw USB device node allowed through from `sfh`.
## Networking ## Networking
@@ -113,7 +113,7 @@ in
"rtsp://admin:@reolink-living-room:554/h264Preview_01_main" "rtsp://admin:@reolink-living-room:554/h264Preview_01_main"
]; ];
webcam_office = [ webcam_office = [
"ffmpeg:device?video=/dev/video0&video_size=1024x576#video=h264" "ffmpeg:device?video=/dev/hass-webcam/video0&video_size=1024x576#video=h264"
]; ];
}; };
}; };
+10 -2
View File
@@ -175,10 +175,15 @@ in
}; };
systemd.services = { systemd.services = {
"systemd-nspawn@hass".serviceConfig.DeviceAllow = [ "systemd-nspawn@hass".serviceConfig = {
DeviceAllow = [
"char-ttyUSB rw" "char-ttyUSB rw"
"char-video4linux 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 # Coding agents; keep the other containers responsive
"systemd-nspawn@slop-cannon".serviceConfig = { "systemd-nspawn@slop-cannon".serviceConfig = {
CPUWeight = 20; CPUWeight = 20;
@@ -215,7 +220,10 @@ in
readOnly = false; readOnly = false;
}; };
"/dev/bus/usb/001/002".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" = { "/dev/serial/by-id/usb-Nabu_Casa_Home_Assistant_Connect_ZBT-1_ce549704fe38ef11a2c2e5d154516304-if00-port0" = {
readOnly = false; readOnly = false;
mountPoint = "/dev/ttyUSB0"; mountPoint = "/dev/ttyUSB0";