{ pkgs, config, lib, modulesPath, ... }: with lib; let cfg = config.eb.boot; in { options.eb.boot = { type = mkOption { description = "Type of boot. Default bios."; default = null; type = types.enum [ "bios" "uefi" ]; }; qemu = mkOption { description = "Set to true if running in qemu"; default = false; type = types.bool; }; grubInstallDevice = mkOption { description = "The disk to install Grub to"; type = types.nullOr types.str; default = null; }; }; config = mkMerge [ { fileSystems."/" = { device = "/dev/disk/by-label/nixos"; fsType = "ext4"; }; swapDevices = [{ device = "/dev/disk/by-label/swap"; }]; } (mkIf (cfg.type == "bios") { boot.loader = { grub = { enable = true; version = 2; device = cfg.grubInstallDevice; efiSupport = false; useOSProber = true; extraEntries = '' menuentry "Reboot" { reboot } menuentry "Power off" { halt } ''; }; }; }) (mkIf (cfg.type == "uefi") { boot.loader = { systemd-boot = { enable = true; editor = false; configurationLimit = 10; }; efi.canTouchEfiVariables = true; }; fileSystems."/boot" = { device = "/dev/disk/by-label/boot"; fsType = "vfat"; }; }) (mkIf (cfg.qemu) { boot.initrd = { availableKernelModules = [ "virtio_net" "virtio_pci" "virtio_mmio" "virtio_blk" "virtio_scsi" "9p" "9pnet_virtio" ]; kernelModules = [ "virtio_balloon" "virtio_console" "virtio_rng" ]; postDeviceCommands = '' hwclock -s ''; }; services.qemuGuest.enable = true; }) ]; }