flowy: set nixos as default EFI boot entry, always
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
{ ... }:
|
{ lib, pkgs, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./fs.nix
|
./fs.nix
|
||||||
@@ -26,4 +26,32 @@
|
|||||||
# add an entry to boot into Windows, as if it had been launched directly from the BIOS.
|
# add an entry to boot into Windows, as if it had been launched directly from the BIOS.
|
||||||
boot.loader.systemd-boot.rebootForBitlocker = true;
|
boot.loader.systemd-boot.rebootForBitlocker = true;
|
||||||
boot.loader.systemd-boot.windows.primary.efiDeviceHandle = "HD0b";
|
boot.loader.systemd-boot.windows.primary.efiDeviceHandle = "HD0b";
|
||||||
|
|
||||||
|
system.activationScripts.makeDefaultBootEntry = {
|
||||||
|
text = let
|
||||||
|
makeDefaultBootEntry = pkgs.writeShellApplication {
|
||||||
|
name = "makeDefaultBootEntry";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
efibootmgr
|
||||||
|
gnugrep
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
# configure the EFI firmware to boot into NixOS by default.
|
||||||
|
# do this by querying the active boot entry, and just making that be the default.
|
||||||
|
# this is needed on flowy because enabling secure boot / booting into Windows
|
||||||
|
# resets the default boot order; manually reconfiguring that is tiresome.
|
||||||
|
efi=$(efibootmgr)
|
||||||
|
bootCurrent=$(echo "$efi" | grep '^BootCurrent: ')
|
||||||
|
bootCurrent=''${bootCurrent/BootCurrent: /}
|
||||||
|
bootOrder=$(echo "$efi" | grep '^BootOrder: ')
|
||||||
|
bootOrder=''${bootOrder/BootOrder: /}
|
||||||
|
# prepend the current boot entry to the boot order...
|
||||||
|
newBootOrder="$bootCurrent,$bootOrder"
|
||||||
|
# but in a way that's idempotent :)
|
||||||
|
newBootOrder=''${newBootOrder/$bootCurrent,$bootCurrent/$bootCurrent}
|
||||||
|
(set -x; efibootmgr -o "$newBootOrder")
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in lib.getExe makeDefaultBootEntry;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user