From bc05090f5b0d4401187e7727061129615a784b25 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Tue, 8 Oct 2024 19:53:02 +0530 Subject: [PATCH] feat: add support for grub bootloader We require this for setting up a VPS on Hetzner Cloud, since Hetzner uses legacy BIOS boot for its instances. Signed-off-by: Chinmay D. Pai --- modules/nixos/core/default.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/nixos/core/default.nix b/modules/nixos/core/default.nix index 38ce217..6d00afa 100644 --- a/modules/nixos/core/default.nix +++ b/modules/nixos/core/default.nix @@ -20,6 +20,10 @@ description = "Timezone to use for the system"; default = "Asia/Kolkata"; }; + bootloader = lib.mkOption { + type = lib.types.enum ["systemd-boot" "grub"]; + description = "Bootloader to use, can be either `systemd-boot` or `grub`"; + }; }; config = { @@ -38,7 +42,7 @@ snowflake.core.sshd.enable = lib.mkDefault true; boot = { - initrd.systemd.enable = true; + initrd.systemd.enable = config.snowflake.bootloader == "systemd-boot"; initrd.verbose = false; # Default to the latest kernel package. kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; @@ -50,10 +54,17 @@ efi.canTouchEfiVariables = true; # Use systemd-boot for all systems. systemd-boot = { - enable = true; + enable = config.snowflake.bootloader == "systemd-boot"; # Show only last 5 configurations in the boot menu. configurationLimit = lib.mkDefault 5; }; + + grub = { + enable = config.snowflake.bootloader == "grub"; + efiSupport = true; + efiInstallAsRemovable = true; + forceInstall = true; + }; }; };