summaryrefslogtreecommitdiff
path: root/os/core
diff options
context:
space:
mode:
authoradikro <adikro@disroot.org>2026-02-12 00:41:07 +0100
committeradikro <adikro@disroot.org>2026-02-12 00:41:07 +0100
commit1ff6f0eb48961e6482ec1b7d0dd9b606e85ddc79 (patch)
tree62099e5c57c7ffe92777f800ec45ee5d68a16ecf /os/core
parent233e5fb7d43a0736857ee6b9f74967f03b73837c (diff)
disko and bootloader changes
Diffstat (limited to 'os/core')
-rw-r--r--os/core/bootloader.nix106
-rw-r--r--os/core/power.nix64
2 files changed, 89 insertions, 81 deletions
diff --git a/os/core/bootloader.nix b/os/core/bootloader.nix
index 52761f1..7f3a85e 100644
--- a/os/core/bootloader.nix
+++ b/os/core/bootloader.nix
@@ -15,32 +15,50 @@ in
"none"
];
default = "systemd-boot";
- description = "which bootloader to use";
+ description = "Which bootloader to use";
};
- useOSProber = lib.mkOption {
- type = lib.types.bool;
- default = false;
- description = "scan for other operating systems";
- };
- enableEncryption = lib.mkOption {
+
+ efi = lib.mkOption {
type = lib.types.bool;
- default = false;
- description = "Enables LUKS encryption";
+ default = true;
+ description = "Whether the system uses UEFI or Legacy BIOS";
};
- grubDevice = lib.mkOption {
- type = lib.types.str;
- default = "nodev";
+
+ timeout = lib.mkOption {
+ type = lib.types.int;
+ default = 3;
+ description = "Boot menu timeout in seconds";
};
- luksDevice = lib.mkOption {
- type = lib.types.nullOr lib.types.str;
- default = null;
- description = "The underlying partition for LUKS";
+
+ grub = {
+ device = lib.mkOption {
+ type = lib.types.str;
+ default = "nodev";
+ description = "Device to install GRUB to (e.g. /dev/nvme0n1). Use 'nodev' for UEFI.";
+ };
+ useOSProber = lib.mkOption {
+ type = lib.types.bool;
+ default = false;
+ description = "Scan for other operating systems";
+ };
+ defaultEntry = lib.mkOption {
+ type = lib.types.int;
+ default = 0;
+ description = "Index of the default boot entry";
+ };
};
+
+ luks.enable = lib.mkEnableOption "LUKS encryption support";
};
config = lib.mkMerge [
+ # 1. Common Kernel & Initrd Settings
{
boot = {
+ loader = {
+ timeout = cfg.timeout;
+ efi.canTouchEfiVariables = cfg.efi;
+ };
supportedFilesystems = [
"ntfs"
"btrfs"
@@ -49,53 +67,35 @@ in
"quiet"
"splash"
];
- initrd = {
- availableKernelModules = [
- "aesni_intel"
- "cryptd"
- ];
- luks.devices = lib.mkIf (cfg.enableEncryption && cfg.luksDevice != null) {
- "crypted" = {
- device = cfg.luksDevice;
- preLVM = true;
- allowDiscards = true;
- };
- };
- };
+ consoleLogLevel = 0;
+ initrd.availableKernelModules = [
+ "aesni_intel"
+ "cryptd"
+ ];
};
systemd.settings.Manager.DefaultTimeoutStopSec = "5s";
}
+ # 2. Systemd-boot Implementation
(lib.mkIf (cfg.type == "systemd-boot") {
- boot = {
- consoleLogLevel = 0;
- loader = {
- efi.canTouchEfiVariables = true;
- timeout = 0;
- systemd-boot = {
- enable = true;
- editor = false;
- consoleMode = "max";
- };
- };
+ boot.loader.systemd-boot = {
+ enable = true;
+ editor = false;
+ consoleMode = "max";
};
})
+ # 3. GRUB Implementation
(lib.mkIf (cfg.type == "grub") {
- boot.loader = {
- timeout = 3;
- efi.canTouchEfiVariables = cfg.grubDevice == "nodev";
- grub = {
- enable = true;
- device = cfg.grubDevice;
- useOSProber = cfg.useOSProber;
- enableCryptodisk = cfg.enableEncryption;
+ boot.loader.grub = {
+ enable = true;
+ device = cfg.grub.device;
+ efiSupport = cfg.efi;
+ useOSProber = cfg.grub.useOSProber;
+ default = cfg.grub.defaultEntry;
- default = if cfg.useOSProber then 2 else 0;
-
- efiSupport = lib.mkDefault (cfg.grubDevice == "nodev");
- copyKernels = lib.mkIf cfg.enableEncryption true;
- };
+ enableCryptodisk = cfg.luks.enable;
+ copyKernels = true;
};
})
];
diff --git a/os/core/power.nix b/os/core/power.nix
index 3929033..b3dbf91 100644
--- a/os/core/power.nix
+++ b/os/core/power.nix
@@ -2,45 +2,53 @@
config,
lib,
...
-}: let
+}:
+let
cfg = config.os.core.power;
-in {
+in
+{
options.os.core.power = {
enable = lib.mkEnableOption "enables power management";
mode = lib.mkOption {
- type = lib.types.enum ["amd" "intel" "none"];
+ type = lib.types.enum [
+ "amd"
+ "intel"
+ "none"
+ ];
default = "none";
};
};
- config = lib.mkIf cfg.enable (lib.mkMerge [
- {
- powerManagement.powertop.enable = true;
- boot.kernelParams = ["nvme_core.default_ps_max_latency_us=0"];
- }
+ config = lib.mkIf cfg.enable (
+ lib.mkMerge [
+ {
+ powerManagement.powertop.enable = true;
+ boot.kernelParams = [ "nvme_core.default_ps_max_latency_us=0" ];
+ }
- (lib.mkIf (cfg.mode == "amd") {
- services.power-profiles-daemon.enable = true;
- boot.kernelParams = ["amd_pstate=active"];
- })
+ (lib.mkIf (cfg.mode == "amd") {
+ services.power-profiles-daemon.enable = true;
+ boot.kernelParams = [ "amd_pstate=active" ];
+ })
- (lib.mkIf (cfg.mode == "intel") {
- services = {
- power-profiles-daemon.enable = false;
+ (lib.mkIf (cfg.mode == "intel") {
+ services = {
+ power-profiles-daemon.enable = false;
- thermald.enable = true;
- tlp = {
- enable = true;
- settings = {
- START_CHARGE_THRESH_BAT0 = 75;
- STOP_CHARGE_THRESH_BAT0 = 80;
- START_CHARGE_THRESH_BAT1 = 75;
- STOP_CHARGE_THRESH_BAT1 = 80;
- CPU_SCALING_GOVERNOR_ON_AC = "performance";
- CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
+ thermald.enable = true;
+ tlp = {
+ enable = true;
+ settings = {
+ START_CHARGE_THRESH_BAT0 = 75;
+ STOP_CHARGE_THRESH_BAT0 = 80;
+ START_CHARGE_THRESH_BAT1 = 75;
+ STOP_CHARGE_THRESH_BAT1 = 80;
+ CPU_SCALING_GOVERNOR_ON_AC = "performance";
+ CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
+ };
};
};
- };
- })
- ]);
+ })
+ ]
+ );
}