nexoniarz-config-nixos-laptop/modules/power.nix
Nexoniarz 654a689fe1 Bring laptop in line with desktop config: Plasma 6, Limine, module split
The laptop was still on the Hyprland-era Pantheon commit while the desktop
moved to KDE Plasma 6 + Limine and split system.nix into focused modules.
This brings over everything that isn't hardware, unchanged, so both machines
stay diffable:

- Plasma 6 on Wayland with SDDM, Konsole, gruvbox icons, KDE MIME defaults
  (replaces Pantheon/LightDM; libreoffice-qt6 replaces the GTK build)
- Limine bootloader with the gruvbox theme, replacing systemd-boot
- system.nix split into boot/networking/locale/nix-settings/security
- flakes + nix-command, sysctl hardening extras (yama, tcp_timestamps),
  geoclue off, captive-portal probe off
- package parity: obs-studio, lmms, go, qemu, KDE utilities, lean SDR++ and
  rtl_433 overrides with hardware.rtl-sdr

Hardware and power are adapted rather than copied:

- hardware.nix keeps the AMD 680M + RTX 4050 PRIME offload setup, asusd and
  supergfxd, v4l2loopback webcam and the DualSense ERTM fix; OpenRGB and
  the desktop's single-GPU block are dropped, keyboard lighting is asusctl
- power.nix is new: power-profiles-daemon for Plasma's profile switcher,
  lid-close handling via the current logind.settings.Login spelling,
  powertop/acpi, notes on asusctl charge limits
- no acpi_enforce_resources=lax, ACPI owns the EC asusd drives here
- touchpad defaults, and firewall openings so the hotspot script's shared
  connection can hand out DHCP/DNS
- pinentry-qt instead of the desktop's leftover pinentry-rofi, blueman
  dropped in favour of Plasma's bluedevil

hardware-configuration.nix stays tracked here (unlike the desktop, which
gitignores it) since it's the only record of this machine's disk layout.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-25 00:02:56 +02:00

48 lines
2.1 KiB
Nix

{ config, lib, pkgs, ... }:
{
# Suspend-to-RAM support and the powersave plumbing Plasma builds on:
# plasma6.nix turns powerdevil and upower on when this is set, and it
# defaults to true — spelled out here because on a laptop it matters.
powerManagement.enable = true;
# Backs Plasma's Power Profiles switcher (Performance / Balanced /
# Power Saver in the battery applet). Plasma already defaults it on; kept
# explicit since it's the one knob that actually changes CPU behaviour.
# Mutually exclusive with tlp and auto-cpufreq — don't add either.
services.power-profiles-daemon.enable = true;
# Lid behaviour. Closing the lid suspends on battery, but only locks when
# docked or on AC, so an external-monitor setup keeps running with the lid
# shut. Renamed options: this is services.logind.settings.Login now, the
# old services.logind.lidSwitch spelling is deprecated in 26.05.
services.logind.settings.Login = {
HandleLidSwitch = "suspend";
HandleLidSwitchExternalPower = "lock";
HandleLidSwitchDocked = "ignore";
HandlePowerKey = "suspend";
};
# Hibernate isn't available and won't be: swap is zram-only (see
# modules/boot.nix), and security.protectKernelImage in modules/security.nix
# blocks the kexec path hibernation resume needs anyway.
# Battery longevity is asusd's department rather than a NixOS option —
# there's no hardware.asus module in nixpkgs. Set it once and asusd
# persists it across reboots:
# asusctl -c 80 # stop charging at 80%
# asusctl -c 100 # back to full, before a trip
# Fan curves and keyboard lighting likewise: `asusctl profile -l`,
# `asusctl aura -h`.
# amd_pstate is left at the kernel's own default. Forcing
# "amd_pstate=active" is the usual tweak for Zen 3+ laptops, but 6.18
# already picks it when the firmware advertises CPPC, so pinning it here
# would only matter if the BIOS regressed:
# boot.kernelParams = [ "amd_pstate=active" ];
environment.systemPackages = with pkgs; [
powertop # `powertop --auto-tune` and per-process wakeup accounting
acpi # quick battery/thermal readout from a terminal
];
}