From 7762d471db115345914de0ca84ca6d33d9a23607 Mon Sep 17 00:00:00 2001 From: ska Date: Mon, 22 Dec 2025 16:05:18 +0000 Subject: [PATCH] Update configuration.nix --- configuration.nix | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/configuration.nix b/configuration.nix index 1727523..c4dc575 100644 --- a/configuration.nix +++ b/configuration.nix @@ -230,15 +230,21 @@ ROOT_SRC="$($FINDMNT -n -o SOURCE / || true)" [ -z "$ROOT_SRC" ] && exit 0 - DEV="$ROOT_SRC" - while PARENT="$($LSBLK -no PKNAME "$DEV" 2>/dev/null)"; [ -n "$PARENT" ]; do - DEV="/dev/$PARENT" - done + # Resolve to top-level disk exactly once + PARENT="$($LSBLK -ndo PKNAME "$ROOT_SRC" 2>/dev/null || true)" + if [ -n "$PARENT" ]; then + ROOT_DEV="/dev/$PARENT" + else + ROOT_DEV="$ROOT_SRC" + fi - DEV_NAME="$($BASENAME "$DEV")" + DEV_NAME="$($BASENAME "$ROOT_DEV")" + + # Sanity check: ensure device exists before watching + [ ! -e "/sys/class/block/$DEV_NAME" ] && exit 0 while [ -e "/sys/class/block/$DEV_NAME" ]; do - $SLEEP 0.5 + $SLEEP 1 done $SYSTEMCTL poweroff