summary refs log tree commit diff stats
path: root/modules/laptop.nix
blob: 3d6894ccba163e80d089640bb1ce96b846e267e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ config, pkgs, ... }:

{ boot.kernelModules = [ "coretemp" ];
  boot.extraModulePackages = with config.boot.kernelPackages; [
    x86_energy_perf_policy
  ];

  hardware = {
    bluetooth.enable = true;
  };

  environment.systemPackages = with pkgs; [
    powerstat
    powertop

    arandr
    autorandr
    disper
  ];

  # powerManagement.resumeCommands = ''
  #   AUTORANDR="autorandr -c"

  #   detect_display()
  #   {
  #     for X in /tmp/.X11-unix/X*; do
  #       D="''${X##/tmp/.X11-unix/X}"
  #       user=$(who | awk -vD="$D" '$5 ~ "\\(:"D"\\)$" {print $1}')
  #       if [ x"$user" != x"" ]; then
  #         export DISPLAY=":$D"
  #         /bin/su -c "''${AUTORANDR}" "$user"
  #       fi
  #     done
  #   }

  #   case "$1" in
  #     thaw|resume)
  #       detect_display
  #       ;;
  #   esac
  # '';

  programs.light.enable = true;

  services.logind.extraConfig = ''
    IdleAction=suspend
    IdleActionSec=600
  '';

  services.physlock.enable = false;

  services.tlp = {
    enable = true;
    extraConfig = ''
      CPU_SCALING_GOVERNOR_ON_BAT=powersave
    '';
  };

  services.udev.extraRules = ''
    # ACTION=="change", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/alan/.Xauthority", RUN+="${pkgs.autorandr}/bin/autorandr -c"
  '';

  services.xserver = {
    libinput = {
      enable = true;
      naturalScrolling = true;
      disableWhileTyping = true;
    };
  };

  systemd.services.nixos-upgrade.unitConfig.ConditionACPower = true;
  systemd.services.nix-gc.unitConfig.ConditionACPower = true;
}