From d57df5556617aa207277283223d0fe793c5badb4 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sat, 2 Feb 2013 21:10:09 -0500 Subject: [PATCH] gummiboot-builder: When NIXOS_INSTALL_GRUB is set and efibootmgr is used, prepend the gummiboot entry to the boot entries list --- .../boot/loader/gummiboot/gummiboot-builder.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/system/boot/loader/gummiboot/gummiboot-builder.py b/modules/system/boot/loader/gummiboot/gummiboot-builder.py index 5da9746cdbd..8729452efbf 100644 --- a/modules/system/boot/loader/gummiboot/gummiboot-builder.py +++ b/modules/system/boot/loader/gummiboot/gummiboot-builder.py @@ -120,6 +120,22 @@ def update_efibootmgr(path): "-p", "@efiPartition@", ]) + efibootmgr_entries = subprocess.check_output(["@efibootmgr@/sbin/efibootmgr"]).split("\n") + for entry in efibootmgr_entries: + columns = entry.split() + if len(columns) > 1 and columns[0] == "BootOrder:": + boot_order = columns[1].split(',') + if len(columns) > 2: + if ' '.join(columns[1:3]) == "NixOS gummiboot": + bootnum = columns[0][4:8] + if not bootnum in boot_order: + boot_order.insert(0, bootnum) + with open("/dev/null", 'w') as dev_null: + subprocess.call([ + "@efibootmgr@/sbin/efibootmgr", + "-o", + ','.join(boot_order) + ], stdout=dev_null) subprocess.call(post_efibootmgr, shell=True) parser = argparse.ArgumentParser(description='Update NixOS-related gummiboot files')