From f54d444e2aaaa38e03851912e06faba93396d615 Mon Sep 17 00:00:00 2001 From: Alex David Date: Sat, 7 Jun 2025 11:16:05 -0700 Subject: [PATCH] Bind all `/dev/video*` for `camera` combinator This updates the `camera` combinator to bind all `/dev/video*` devices found at runtime. This also means bubblewrap won't crash if `camera` is specified but there is no camera attached. --- combinators.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/combinators.nix b/combinators.nix index dcf794c..0b79e05 100644 --- a/combinators.nix +++ b/combinators.nix @@ -18,7 +18,12 @@ in rec { set-hostname = hostname: state: state // { inherit hostname; }; tmpfs = path: unsafe-add-raw-args "--tmpfs ${escape path}"; - camera = unsafe-add-raw-args "--dev-bind /dev/video0 /dev/video0"; + camera = add-runtime '' + for v in /dev/video*; do + [ -e "$v" ] || continue + RUNTIME_ARGS+=(--dev-bind "$v" "$v") + done + ''; # safety: jail/lib.nix asserts that name is a valid shell variable name fwd-env = name: set-env name (noescape "\"\$${name}\"");