dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
commit 8fd73c922a733a50ddef3a2223a1ae26229dc65a parent 8d9a783f70dc3d96fda99c4b8d27948e4eada262 Author: maydayv7 <maydayv7@gmail.com> Date: Wed, 27 Apr 2022 19:49:26 +0530 fix: Refine `boot` Module
Diffstat:
| M | devices/Futura.nix | | | 2 | +- |
| M | devices/Vortex.nix | | | 2 | +- |
| M | modules/default.nix | | | 9 | +++++---- |
| M | modules/hardware/boot.nix | | | 88 | +++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------- |
4 files changed, 66 insertions(+), 35 deletions(-)
diff --git a/devices/Futura.nix b/devices/Futura.nix @@ -7,7 +7,7 @@ locale = "en_IN.UTF-8"; update = "weekly"; - kernel = "linux_5_4"; + kernel = "5_4"; hardware = { boot = "efi"; cores = 4; diff --git a/devices/Vortex.nix b/devices/Vortex.nix @@ -7,7 +7,7 @@ timezone = "Asia/Kolkata"; locale = "en_IN.UTF-8"; - kernel = "linux_lqx"; + kernel = "lqx"; kernelModules = ["nvme" "thunderbolt"]; hardware = { diff --git a/modules/default.nix b/modules/default.nix @@ -118,12 +118,13 @@ in { # Kernel Configuration boot = { initrd.availableKernelModules = - kernelModules - ++ ["ahci" "sd_mod" "usbhid" "usb_storage" "xhci_pci"]; + if (kernelModules != null) + then kernelModules ++ ["ahci" "sd_mod" "usbhid" "usb_storage" "xhci_pci"] + else []; kernelPackages = - if (kernel == "linux_zfs") + if (kernel == "zfs") then pkgs.zfs.latestCompatibleLinuxPackages - else pkgs.linuxKernel.packages."${kernel}"; + else pkgs.linuxKernel.packages."${"linux_" + kernel}"; }; # Package Configuration diff --git a/modules/hardware/boot.nix b/modules/hardware/boot.nix @@ -1,45 +1,75 @@ { config, + options, lib, ... -}: { - options.hardware.boot = lib.mkOption { +}: let + inherit (lib) mkDefault mkForce mkIf mkMerge mkOption optional types; + loader = config.hardware.boot; +in { + options.hardware.boot = mkOption { description = "Supported Boot Firmware"; - type = lib.types.enum ["mbr" "efi"]; + type = types.nullOr (types.enum ["mbr" "efi"]); default = "mbr"; }; ## Boot Configuration ## - config = lib.mkIf (config.hardware.boot == "efi") { - boot = { - tmpOnTmpfs = true; - cleanTmpDir = !config.boot.tmpOnTmpfs; + config = + { + warnings = + optional (loader == null) + (options.hardware.boot.description + " is unset"); + } + // mkIf (loader != null) (mkMerge [ + { + boot = { + tmpOnTmpfs = true; + cleanTmpDir = !config.boot.tmpOnTmpfs; - # Plymouth - consoleLogLevel = 0; - initrd.verbose = false; - plymouth.enable = true; - kernelParams = [ - "quiet" - "splash" - "boot.shell_on_fail" - "i915.fastboot=1" - "loglevel=3" - "rd.systemd.show_status=false" - "rd.udev.log_level=3" - "udev.log_priority=3" - ]; + # Plymouth + consoleLogLevel = 0; + initrd.verbose = false; + plymouth.enable = true; + kernelParams = [ + "quiet" + "splash" + "boot.shell_on_fail" + "i915.fastboot=1" + "loglevel=3" + "rd.systemd.show_status=false" + "rd.udev.log_level=3" + "udev.log_priority=3" + ]; - # Boot Loader - loader = { - timeout = lib.mkDefault 0; - efi.canTouchEfiVariables = true; - systemd-boot = { + # Boot Loader + loader = { + timeout = lib.mkDefault 0; + grub.enable = mkDefault false; + efi.canTouchEfiVariables = true; + }; + }; + } + + ## GRUB MBR Boot Loader ## + (mkIf (config.hardware.boot == "mbr") { + boot.loader.grub = { + enable = mkForce true; + device = "nodev"; + efiSupport = true; + zfsSupport = true; + useOSProber = true; + splashImage = null; + extraConfig = "set timeout_style=hidden"; + }; + }) + + ## SystemD EFI Boot Loader ## + (mkIf (config.hardware.boot == "efi") { + boot.loader.systemd-boot = { enable = true; editor = false; configurationLimit = 100; }; - }; - }; - }; + }) + ]); }