mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:59:23 +08:00
全部整理完成了
This commit is contained in:
20
flake.nix
20
flake.nix
@@ -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 =
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user