feat(system): add laptop power preset module

New `nomarchy.system.laptop.{enable,thermald}` options. `enable`
defaults to `formFactor == "laptop"`, so the installer's existing
formFactor write auto-flips the preset on without installer changes.

The module wires TLP (governors + 75/80 charge thresholds),
force-disables power-profiles-daemon (mutually exclusive with TLP),
enables upower and thermald (x86_64), adds the brightnessctl udev
rule so the existing brightness scripts work without root, and sets
a logind lid-switch policy that resolves to suspend-then-hibernate
when `hibernation.enable` is on, plain suspend otherwise.

Closes the "Form-factor → laptop preset auto-enable" Now item and
the "Laptop preset module" Next item from docs/ROADMAP.md in one
change.
This commit is contained in:
Bernardo Magri
2026-04-26 08:31:19 +01:00
parent 7086a6f29c
commit 034da701a3
5 changed files with 82 additions and 5 deletions

View File

@@ -35,9 +35,9 @@ Defined in `core/system/options.nix`; wired in `core/system/network.nix`.
### `nomarchy.system.formFactor`
`enum [ "laptop" "desktop" ]`, default `"laptop"`. Drives UI affordances and (eventually) lid handling / TLP. The installer auto-detects via `/sys/class/power_supply/BAT*`. The default is `"laptop"` because the battery widget renders empty when no battery is present — safe on a desktop, useful on a laptop.
`enum [ "laptop" "desktop" ]`, default `"laptop"`. Drives UI affordances and the laptop power preset. The installer auto-detects via `/sys/class/power_supply/BAT*`. The default is `"laptop"` because the battery widget renders empty when no battery is present — safe on a desktop, useful on a laptop.
Wired in `features/desktop/waybar/default.nix` (filters the battery widget out on desktop) and `features/scripts/battery-monitor.nix` (skips the timer on desktop).
Wired in `features/desktop/waybar/default.nix` (filters the battery widget out on desktop), `features/scripts/battery-monitor.nix` (skips the timer on desktop), and `nomarchy.system.laptop.enable` (defaults true when this is `"laptop"`).
### `nomarchy.system.theme`
@@ -67,6 +67,14 @@ Wired in `features/desktop/waybar/default.nix` (filters the battery widget out o
`int`, default `30`. Idle minutes before suspend-then-hibernate fires.
### `nomarchy.system.laptop.enable`
`bool`, default `nomarchy.system.formFactor == "laptop"`. Laptop power preset: TLP (with sane AC/battery governors and ThinkPad-style 75/80 charge thresholds), `services.upower`, `services.thermald` (gated by `laptop.thermald`), and a brightnessctl udev rule so the existing `nomarchy-brightness-{display,keyboard}` scripts run without root. Force-disables `services.power-profiles-daemon` (mutually exclusive with TLP) — to use PPD instead, set `laptop.enable = false` and wire it yourself. Lid-close action defers to `nomarchy.system.hibernation.enable`: `suspend-then-hibernate` when on, `suspend` otherwise. Charge thresholds are only honored on supported hardware (ThinkPad, some ASUS); harmless warning elsewhere.
### `nomarchy.system.laptop.thermald`
`bool`, default `true` on x86_64. Enables `services.thermald` (Intel thermal daemon). Harmless no-op on AMD; gated off on aarch64.
### `nomarchy.system.containers.enable`
`bool`, default `false`. Rootless Podman with Docker compatibility (`docker``podman`), plus `podman-compose`, `podman-tui`, and `dive`.