nixos-server: turn off backlight after boot, add video group and light

- Add server-backlight-off service to set backlight to 0 ~65s after boot
  (consoleblank only blanks framebuffer; backlight stays on otherwise)
- Enable programs.light and add danny to video group for light(1) at console
- At console: light -S 100 to restore brightness

Made-with: Cursor
This commit is contained in:
DannyDannyDanny 2026-02-28 11:49:04 +01:00
parent a3ae773dff
commit bfe7ae5622

View file

@ -18,12 +18,28 @@ in
boot.kernelParams = [ "consoleblank=60" ]; # blank TTY after 60s to reduce burn-in boot.kernelParams = [ "consoleblank=60" ]; # blank TTY after 60s to reduce burn-in
# Turn off panel backlight after boot so the screen actually dims (consoleblank only blanks framebuffer).
# At the console, run: light -S 100 (or any 0100) to restore brightness.
programs.light.enable = true;
systemd.services.server-backlight-off = {
description = "Turn off panel backlight after console idle (reduce burn-in)";
after = [ "multi-user.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "oneshot";
script = ''
${pkgs.coreutils}/bin/sleep 65
for d in /sys/class/backlight/*; do
[ -f "$d/brightness" ] && echo 0 > "$d/brightness" 2>/dev/null || true
done
'';
};
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = [ "nix-command" "flakes" ];
system.stateVersion = "24.11"; system.stateVersion = "24.11";
users.users.danny = { users.users.danny = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" "video" ]; # video: backlight control via light(1)
# SSH keys: push via scp, don't commit. NixOS does not manage authorized_keys so scpd keys persist. # SSH keys: push via scp, don't commit. NixOS does not manage authorized_keys so scpd keys persist.
# Example: scp ~/.ssh/id_*_github.pub danny@server:/tmp/ then on server: mkdir -p ~/.ssh; cat /tmp/*.pub >> ~/.ssh/authorized_keys # Example: scp ~/.ssh/id_*_github.pub danny@server:/tmp/ then on server: mkdir -p ~/.ssh; cat /tmp/*.pub >> ~/.ssh/authorized_keys
}; };