83 lines
1.8 KiB
Nix
83 lines
1.8 KiB
Nix
{ pkgs, config, lib, ... }:
|
|
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.postDeviceCommands = ''
|
|
# Set the system time from the hardware clock to work around a
|
|
# bug in qemu-kvm > 1.5.2 where the VM clock is initialized
|
|
# to the *boot time* of the host.
|
|
hwclock -s
|
|
'';
|
|
|
|
services.qemuGuest.enable = true;
|
|
})
|
|
];
|
|
}
|