All checks were successful
CI / Format Check (push) Successful in 3s
CI / Flake Check (push) Successful in 1m46s
CI / Evaluate Key Configurations (nix-builder) (push) Successful in 13s
CI / Evaluate Key Configurations (nix-desktop1) (push) Successful in 9s
CI / Evaluate Key Configurations (nix-laptop1) (push) Successful in 9s
CI / Evaluate Artifacts (installer-iso-nix-laptop1) (push) Successful in 20s
CI / Evaluate Artifacts (lxc-nix-builder) (push) Successful in 13s
CI / Build and Publish Documentation (push) Successful in 10s
131 lines
4.1 KiB
Nix
131 lines
4.1 KiB
Nix
# ============================================================================
|
|
# Laptop Configuration
|
|
# ============================================================================
|
|
# Hardware and boot configuration for laptop systems with mobile features.
|
|
# Includes power management, lid switch handling, and Intel graphics fixes.
|
|
|
|
{
|
|
config,
|
|
lib,
|
|
modulesPath,
|
|
...
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.athenix.hw.nix-laptop;
|
|
in
|
|
{
|
|
imports = [
|
|
(modulesPath + "/installer/scan/not-detected.nix")
|
|
];
|
|
|
|
options.athenix.hw.nix-laptop = mkOption {
|
|
type = types.submodule {
|
|
options = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = "Enable laptop hardware configuration with power management.";
|
|
};
|
|
};
|
|
};
|
|
default = { };
|
|
description = "Laptop hardware type configuration.";
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
# ========== Boot Configuration ==========
|
|
|
|
boot.initrd.availableKernelModules = [
|
|
"xhci_pci" # USB 3.0 support
|
|
"thunderbolt" # Thunderbolt support
|
|
"nvme" # NVMe SSD support
|
|
"usb_storage" # USB storage devices
|
|
"sd_mod" # SD card support
|
|
"sdhci_pci" # SD card host controller
|
|
];
|
|
boot.initrd.kernelModules = [ ];
|
|
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
|
boot.extraModulePackages = [ ];
|
|
boot.kernelParams = [
|
|
"quiet" # Minimal boot messages
|
|
"splash" # Show Plymouth boot splash
|
|
"boot.shell_on_fail" # Emergency shell on boot failure
|
|
"udev.log_priority=3" # Reduce udev logging
|
|
"rd.systemd.show_status=auto" # Show systemd status during boot
|
|
"i915.enable_psr=0" # Disable Panel Self Refresh (stability)
|
|
"i915.enable_dc=0" # Disable display power saving
|
|
"i915.enable_fbc=0" # Disable framebuffer compression
|
|
"mem_sleep_default=deep" # Use deep sleep (S3) by default
|
|
];
|
|
|
|
# ========== Hardware Configuration ==========
|
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
|
|
|
# ========== Filesystem Configuration ==========
|
|
athenix.host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
|
athenix.host.filesystem.swapSize = lib.mkDefault "34G"; # Larger swap for hibernation
|
|
boot.resumeDevice = "/dev/nvme0n1p2"; # Resume from swap partition
|
|
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
|
|
|
# ========== Power Management ==========
|
|
systemd.sleep.extraConfig = ''
|
|
SuspendState=mem
|
|
HibernateDelaySec=30m
|
|
'';
|
|
powerManagement.enable = lib.mkDefault true;
|
|
powerManagement.powertop.enable = lib.mkDefault true;
|
|
services = {
|
|
upower.enable = lib.mkDefault true;
|
|
logind.settings = {
|
|
Login = {
|
|
HandleLidSwitch = "suspend";
|
|
HandleLidSwitchExternalPower = "suspend";
|
|
HandleLidSwitchDocked = "ignore";
|
|
PowerKey = "hibernate";
|
|
PowerKeyLongPress = "poweroff";
|
|
};
|
|
};
|
|
power-profiles-daemon.enable = false;
|
|
tlp = {
|
|
enable = true;
|
|
settings = {
|
|
CPU_SCALING_GOVERNOR_ON_AC = "performance";
|
|
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
|
|
|
|
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
|
|
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
|
|
|
|
CPU_MIN_PERF_ON_AC = 0;
|
|
CPU_MAX_PERF_ON_AC = 100;
|
|
CPU_MIN_PERF_ON_BAT = 0;
|
|
CPU_MAX_PERF_ON_BAT = 20;
|
|
|
|
#Optional helps save long term battery health
|
|
START_CHARGE_THRESH_BAT0 = 40; # 40 and below it starts to charge
|
|
STOP_CHARGE_THRESH_BAT0 = 80; # 80 and above it stops charging
|
|
};
|
|
};
|
|
auto-cpufreq = {
|
|
enable = lib.mkDefault true;
|
|
settings = {
|
|
battery = {
|
|
governor = "powersave";
|
|
turbo = "never";
|
|
};
|
|
charger = {
|
|
governor = "performance";
|
|
turbo = "auto";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
athenix.sw.enable = lib.mkDefault true;
|
|
athenix.sw.desktop.enable = lib.mkDefault true;
|
|
};
|
|
}
|