Nixos currently boots via GRUB2 using default alphanumeric named bzimage and initrd from ESP. Objective is to duplicate and rename kernel and initrd at time of update so Refind configuration can remain unchanged even when bzimage and initrd alphanumeric names change.
Nixos 26.05 configuration.nix snippet:
system.activationScripts.updateStaticKernels = {
text = ''
TARGET_DIR="/boot/kernels"
mkdir -p "$TARGET_DIR"
# Copy and give the kernel a .efi extension so rEFInd recognizes it as a valid EFI loader stub
cp -f "${config.system.build.kernel}/bzImage" "$TARGET_DIR/vmlinuz.efi"
cp -f "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}" "$TARGET_DIR/initrd"
echo "Static kernel and initrd copied successfully to $TARGET_DIR."
'';
};
refind failed boot entries subsequently disabled due to "invalid loader":
menuentry "NixOS" {
icon \EFI\refind\icons\os_nixos.png
volume "NIX"
loader \kernel\bzimage
initrd \kernel\initrd
options "root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx init=/nixos-init loglevel=4 lsm=landlock,yama,bpf"a
disabled
}
menuentry "NixOS" {
icon \EFI\refind\icons\os_nixos.png
volume "NIX"
loader \kernel\vmlinuz.efi
initrd \kernel\initrd
options "root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx init=/nixos-init loglevel=4 lsm=landlock,yama,bpf"
disabled
}
Can Refind boot NixOS? If so, how?