全部整理完成了

This commit is contained in:
2023-07-27 23:05:04 +08:00
parent e3f5704afc
commit 6540a7d980
2 changed files with 18 additions and 25 deletions

View File

@@ -158,25 +158,7 @@
};
boot.grub =
{
entries = localLib.stripeTabs
''
menuentry "Windows" {
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --set=root 7317-1DB6
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
menuentry "Windows for malware" {
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --set=root 7321-FA9C
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
'';
windowsEntries = { "7317-1DB6" = "Windows"; "7321-FA9C" = "Windows for malware"; };
installDevice = "efi";
};
system =

View File

@@ -5,15 +5,16 @@ inputs:
grub =
{
timeout = mkOption { type = types.int; default = 5; };
entries = mkOption { type = types.nullOr types.str; };
windowsEntries = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; };
installDevice = mkOption { type = types.str; }; # "efi" using efi, or dev path like "/dev/sda" using bios
};
};
config =
let
inherit (inputs.lib) mkMerge mkIf;
inherit (inputs.localLib) mkConditional;
inherit (inputs.localLib) mkConditional attrsToList stripeTabs;
inherit (inputs.config.nixos) boot;
inherit (builtins) concatStringsSep map;
in mkMerge
[
# generic
@@ -26,10 +27,20 @@ inputs:
}
# grub.timeout
{ boot.loader.timeout = boot.grub.timeout; }
# grub.entries
(
mkIf (boot.grub.entries != null) { boot.loader.grub.extraEntries = boot.grub.entries; }
)
# grub.windowsEntries
{
boot.loader.grub.extraEntries = concatStringsSep "" (map (system: stripeTabs
''
menuentry "${system.value}" {
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --set=root ${system.name}
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
'') (attrsToList boot.grub.windowsEntries));
}
# grub.installDevice
(
mkConditional (boot.grub.installDevice == "efi")