modules/boot: move bootloaders to module

This commit is contained in:
Infinidoge 2021-11-21 19:58:03 -05:00
parent c18b633ea9
commit bca6c11270
7 changed files with 66 additions and 45 deletions

56
modules/modules/boot.nix Normal file
View file

@ -0,0 +1,56 @@
{ config, options, lib, ... }:
with lib;
with lib.hlissner;
let
cfg = config.modules.boot;
opt = options.modules.boot;
in
{
options.modules.boot = with types; {
timeout = mkOpt (nullOr int) 3;
grub = {
enable = mkBoolOpt false;
};
systemd-boot.enable = mkBoolOpt false;
};
config = mkMerge [
{
assertions = [
{
assertion = (count (v: v) [ cfg.grub.enable cfg.systemd-boot.enable ]) == 1;
message = "Must enable one and only one bootloader";
}
];
boot.loader.timeout = mkAliasDefinitions opt.timeout;
}
(mkIf cfg.grub.enable {
boot.loader = {
grub = {
enable = mkDefault true;
device = mkDefault "nodev";
efiSupport = mkDefault true;
useOSProber = mkDefault false;
efiInstallAsRemovable = mkDefault true;
};
efi = {
canTouchEfiVariables = mkDefault false;
efiSysMountPoint = mkDefault "/boot/efi";
};
};
})
(mkIf cfg.systemd-boot.enable {
boot.loader = {
systemd-boot = {
enable = mkDefault true;
editor = false;
consoleMode = "2";
};
efi.canTouchEfiVariables = true;
};
})
];
}