refactor(nixosmodules): move boot config to module
This commit is contained in:
parent
2d29c8ffef
commit
5bef7c46a6
9 changed files with 61 additions and 57 deletions
51
nixosModules/boot.nix
Normal file
51
nixosModules/boot.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
let
|
||||
moduleName = "boot-config";
|
||||
cfg = config."${moduleName}";
|
||||
in
|
||||
{
|
||||
options = {
|
||||
"${moduleName}" = {
|
||||
enable = lib.mkEnableOption "Enable ${moduleName}.";
|
||||
bootloader = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
example = "systemd-boot";
|
||||
description = "What bootloader to use.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot = {
|
||||
loader =
|
||||
{
|
||||
timeout = 5;
|
||||
efi.canTouchEfiVariables = true;
|
||||
}
|
||||
// lib.mkIf (cfg.bootloader == "systemd-boot") {
|
||||
systemd-boot.enable = true;
|
||||
systemd-boot.configurationLimit = 5;
|
||||
};
|
||||
kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
|
||||
initrd.availableKernelModules = [
|
||||
"ahci"
|
||||
"nvme"
|
||||
"sd_mod"
|
||||
"usb_storage"
|
||||
"usbhid"
|
||||
"xhci_pci"
|
||||
"rtsx_pci_sdmmc"
|
||||
];
|
||||
};
|
||||
services.dbus = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -11,10 +11,13 @@ in
|
|||
{
|
||||
imports = [
|
||||
./nix-config.nix
|
||||
./boot.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
"${moduleName}".enable = lib.mkEnableOption "Enable ${moduleName}.";
|
||||
"${moduleName}" = {
|
||||
enable = lib.mkEnableOption "Enable ${moduleName}.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
|
|
@ -10,7 +10,9 @@ let
|
|||
in
|
||||
{
|
||||
options = {
|
||||
"${moduleName}".enable = lib.mkEnableOption "Enable ${moduleName}.";
|
||||
"${moduleName}" = {
|
||||
enable = lib.mkEnableOption "Enable ${moduleName}.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue