Skip to content

Commit 3d16915

Browse files
committed
install.sh: fix false-negative in system-profile verification check
nix profile symlinks resolve to absolute /nix/store/... paths, which [[ -e ]] follows against the live ISO's own root rather than /mnt. That made "system profile exists" report FAIL on a real, successful fonseca install even though nixos-install's own success banner and a manual nixos-enter check both confirmed the profile was set correctly. exists_under_mnt() walks the symlink chain by hand and rebases any absolute target onto /mnt before testing it.
1 parent 4b42984 commit 3d16915

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

install.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,34 @@ check() {
243243

244244
exists() { [[ -e "$1" ]]; }
245245

246+
# Like exists(), but for paths under /mnt whose symlink chain may end in an
247+
# *absolute* /nix/store/... target (nix profiles are set this way). A plain
248+
# `[[ -e ]]` would resolve that absolute target against the live ISO's own /,
249+
# not /mnt, and report a false failure even though the target exists correctly
250+
# under /mnt/nix/store. Walk the chain by hand, rebasing absolute targets onto
251+
# /mnt.
252+
exists_under_mnt() {
253+
local path="$1" hops=0
254+
while [[ -L "$path" ]]; do
255+
(( hops++ > 20 )) && return 1 # symlink loop guard
256+
local target
257+
target="$(readlink "$path")"
258+
if [[ "$target" == /* ]]; then
259+
path="/mnt$target"
260+
else
261+
path="$(dirname "$path")/$target"
262+
fi
263+
done
264+
[[ -e "$path" ]]
265+
}
266+
246267
# With efiInstallAsRemovable the binary lands at EFI/BOOT/BOOTX64.EFI; without
247268
# it, at EFI/NixOS/grubx64.efi. Either is a successfully installed bootloader.
248269
have_boot_efi() {
249270
[[ -n "$(find /mnt/boot/EFI \( -iname 'grub*.efi' -o -iname 'bootx64.efi' \) -print -quit 2>/dev/null)" ]]
250271
}
251272

252-
check "system profile exists" exists /mnt/nix/var/nix/profiles/system
273+
check "system profile exists" exists_under_mnt /mnt/nix/var/nix/profiles/system
253274
check "/etc/NIXOS exists" exists /mnt/etc/NIXOS
254275
check "bootloader EFI binary present on the ESP" have_boot_efi
255276
check "grub.cfg present on the ESP" exists /mnt/boot/grub/grub.cfg

0 commit comments

Comments
 (0)