2021-10-07 09:59:54 +02:00
|
|
|
{ pkgs, config, lib, modulesPath, ... }:
|
2021-10-05 23:45:02 +02:00
|
|
|
with lib;
|
|
|
|
|
2021-10-18 21:45:28 +02:00
|
|
|
let
|
|
|
|
cfg = config.eb.boot;
|
|
|
|
in
|
|
|
|
{
|
2021-10-05 23:45:02 +02:00
|
|
|
options.eb.boot = {
|
|
|
|
type = mkOption {
|
|
|
|
description = "Type of boot. Default bios.";
|
|
|
|
default = null;
|
|
|
|
type = types.enum [ "bios" "uefi" ];
|
|
|
|
};
|
|
|
|
|
2021-10-18 21:45:28 +02:00
|
|
|
qemu = mkEnableOption {
|
2021-10-05 23:45:02 +02:00
|
|
|
description = "Set to true if running in qemu";
|
|
|
|
};
|
|
|
|
|
|
|
|
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) {
|
2021-10-07 09:59:54 +02:00
|
|
|
boot.initrd = {
|
|
|
|
availableKernelModules = [ "virtio_net" "virtio_pci" "virtio_mmio" "virtio_blk" "virtio_scsi" "9p" "9pnet_virtio" ];
|
|
|
|
kernelModules = [ "virtio_balloon" "virtio_console" "virtio_rng" ];
|
|
|
|
postDeviceCommands =
|
|
|
|
''
|
2021-10-18 21:45:28 +02:00
|
|
|
hwclock -s
|
2021-10-07 09:59:54 +02:00
|
|
|
'';
|
|
|
|
};
|
2021-10-05 23:45:02 +02:00
|
|
|
|
|
|
|
services.qemuGuest.enable = true;
|
2021-10-18 21:45:28 +02:00
|
|
|
services.spice-vdagentd.enable = true;
|
2021-10-05 23:45:02 +02:00
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|