From f5abfd5bf6aa74448b37877923f3b409816732e4 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 12 Feb 2026 18:48:41 -0500 Subject: [PATCH] fix(no-rgb): handle transient hardware unavailability during deploy --- modules/no-rgb.nix | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/no-rgb.nix b/modules/no-rgb.nix index b304ecf..9b73ee5 100644 --- a/modules/no-rgb.nix +++ b/modules/no-rgb.nix @@ -17,13 +17,27 @@ ]; text = '' - #!/bin/sh - set -e + # Retry loop to wait for hardware to be ready + NUM_DEVICES=0 + for attempt in 1 2 3 4 5; do + DEVICE_LIST=$(openrgb --noautoconnect --list-devices 2>/dev/null) || DEVICE_LIST="" + NUM_DEVICES=$(echo "$DEVICE_LIST" | grep -cE '^[0-9]+: ') || NUM_DEVICES=0 + if [ "$NUM_DEVICES" -gt 0 ]; then + break + fi + if [ "$attempt" -lt 5 ]; then + sleep 2 + fi + done - NUM_DEVICES=$(openrgb --noautoconnect --list-devices | grep -cE '^[0-9]+: ') + # If no devices found after retries, exit gracefully + if [ "$NUM_DEVICES" -eq 0 ]; then + exit 0 + fi + # Disable RGB on each device for i in $(seq 0 $((NUM_DEVICES - 1))); do - openrgb --noautoconnect --device "$i" --mode direct --color 000000 + openrgb --noautoconnect --device "$i" --mode direct --color 000000 || true done ''; } @@ -31,9 +45,12 @@ in { description = "disable rgb"; + after = [ "systemd-udev-settle.service" ]; serviceConfig = { ExecStart = lib.getExe no-rgb; Type = "oneshot"; + Restart = "on-failure"; + RestartSec = 5; }; wantedBy = [ "multi-user.target" ]; };