2023-07-21 21:46:24 +08:00
|
|
|
inputs:
|
|
|
|
{
|
|
|
|
options.nixos.boot = let inherit (inputs.lib) mkOption types; in
|
|
|
|
{
|
|
|
|
grub =
|
|
|
|
{
|
|
|
|
timeout = mkOption { type = types.int; default = 5; };
|
|
|
|
entries = mkOption { type = types.nullOr types.str; };
|
|
|
|
installDevice = mkOption { type = types.str; }; # "efi" using efi, or dev path like "/dev/sda" using bios
|
|
|
|
};
|
|
|
|
};
|
2023-07-26 23:36:12 +08:00
|
|
|
config =
|
|
|
|
let
|
|
|
|
inherit (inputs.lib) mkMerge mkIf;
|
|
|
|
inherit (inputs.localLib) mkConditional;
|
|
|
|
inherit (inputs.config.nixos) boot;
|
|
|
|
in mkMerge
|
|
|
|
[
|
|
|
|
# generic
|
2023-07-22 14:06:41 +08:00
|
|
|
{
|
2023-07-26 23:36:12 +08:00
|
|
|
boot =
|
2023-07-21 21:46:24 +08:00
|
|
|
{
|
2023-07-26 23:36:12 +08:00
|
|
|
loader.grub = { enable = true; useOSProber = false; };
|
|
|
|
initrd.systemd.enable = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
# grub.timeout
|
|
|
|
{ boot.loader.timeout = boot.grub.timeout; }
|
|
|
|
# grub.entries
|
|
|
|
(
|
|
|
|
mkIf (boot.grub.entries != null) { boot.loader.grub.extraEntries = boot.grub.entries; }
|
|
|
|
)
|
|
|
|
# grub.installDevice
|
|
|
|
(
|
|
|
|
mkConditional (boot.grub.installDevice == "efi")
|
2023-07-21 21:46:24 +08:00
|
|
|
{
|
2023-07-26 23:36:12 +08:00
|
|
|
boot.loader =
|
|
|
|
{
|
|
|
|
efi = { canTouchEfiVariables = true; efiSysMountPoint = "/boot/efi"; };
|
|
|
|
grub = { device = "nodev"; efiSupport = true; };
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{ boot.loader.grub.device = boot.grub.installDevice; }
|
|
|
|
)
|
|
|
|
];
|
2023-07-21 22:02:48 +08:00
|
|
|
}
|