From d9324653dcfde99a73e9ab06cf78123cb1cb4a97 Mon Sep 17 00:00:00 2001 From: Hao Ren Zhou <104418647+haoren-zhou@users.noreply.github.com> Date: Fri, 24 Jul 2026 16:43:25 +0800 Subject: [PATCH] nixos/limine: avoid rewriting boot order on update efibootmgr rejects -o when BootOrder contains IDs without corresponding BootXXXX variables (which can come from certain BIOS implementations). Fix by recreating Limine entry at previous position using -c --index, or use -C if Limine was not in BootOrder. (cherry picked from commit 4dd37d80c3de1be68418ac940ffe2774dd517081) --- .../system/boot/loader/limine/limine-install.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/boot/loader/limine/limine-install.py b/nixos/modules/system/boot/loader/limine/limine-install.py index 4c9db91ad65d..ea9d2c46d0ae 100644 --- a/nixos/modules/system/boot/loader/limine/limine-install.py +++ b/nixos/modules/system/boot/loader/limine/limine-install.py @@ -603,6 +603,14 @@ def install_bootloader() -> None: # If there's already a Limine entry, replace it if limine_boot_entry: boot_order = re.findall(r'BootOrder: ((?:[0-9a-fA-F]{4},?)*)', efibootmgr_output)[0] + normalized_boot_order = boot_order.upper().split(',') + create_options = ['-C'] + if limine_boot_entry.upper() in normalized_boot_order: + create_options = [ + '-c', + '--index', + str(normalized_boot_order.index(limine_boot_entry.upper())), + ] efibootmgr_output = subprocess.check_output([ efibootmgr, @@ -612,13 +620,12 @@ def install_bootloader() -> None: efibootmgr_output = subprocess.check_output([ efibootmgr, - '-c', + *create_options, '-b', limine_boot_entry, '-d', efi_disk, '-p', efi_partition.removeprefix(efi_disk).removeprefix('p'), '-l', f'\\efi\\limine\\{boot_file}', '-L', 'Limine', - '-o', boot_order, ], stderr=subprocess.STDOUT, universal_newlines=True) else: efibootmgr_output = subprocess.check_output([