Subject: RE: [wishlist] Make the GRUB installation procedure smarter

From: muradm <[email-masked]>
Date: Sun, 05 Sep 2021 04:27:25 +0300

First I was using Guix on Lenovo Carbon X1 in parallel with Arch. 
Few times I experiences "NVRAM full" or similar problem, I don't 
recall now. Solution was to reset NVRAM by some procedure. Half a 
year now, I moved to System76 Lemur Pro, where I have only Guix 
alone. Here I have another problem, sometimes it simply does not 
boot, then I have to plug USB, and run grub-install manually to 
recover.

As per discussion on IRC today, I would suggest the folowing 
regarding grub efi, I'm not using other bootloaders, but I suppose 
same logic may apply.

There are two things about grub:

1) /boot/efi/EFI/Guix/grubx64.efi & NVRAM - these are changing 
very very rarely, only when grub version change, boot partition 
change.

2) /boot/grub/* - these are changing only when grub version change 
or new guix generation is created, then grub.cfg is getting 
updated.

Currently, as far as I understand, both of them are getting 
installed with one script from this derivation:
/gnu/store/...-install-bootloader.scm.drv

It could be split into two, one which runs grub-install, i.e. #1 
above, the other which covers #2 above, let's say 
bootloader-phase-1-install and bootloader-phase-2-install 
respectively.

Then, each script can be executed only when derivation is 
changing. With the following exceptions:
- must be executed anyway on "guix system init ..."
- must be executed only if "guix system reconfigure 
  --force-bootloader ..."

Scripts them selves store grub version (via absolute path), thus 
if grub updated, derivations will change.

If for some reason, grub and/or nvram getting broken on boot, user 
has to boot with some kind recovery media anyway.