summary refs log tree commit diff stats
path: root/modules/hardware/laptop.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/hardware/laptop.nix')
-rw-r--r--modules/hardware/laptop.nix77
1 files changed, 77 insertions, 0 deletions
diff --git a/modules/hardware/laptop.nix b/modules/hardware/laptop.nix
new file mode 100644
index 0000000..55dcbd1
--- /dev/null
+++ b/modules/hardware/laptop.nix
@@ -0,0 +1,77 @@
+{ config, pkgs, lib, ... }:
+
+{ 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 = lib.mkDefault true;
+      naturalScrolling = true;
+      disableWhileTyping = true;
+    };
+  };
+
+  systemd.services.nixos-upgrade.unitConfig.ConditionACPower = true;
+  systemd.services.nix-gc.unitConfig.ConditionACPower = true;
+
+  imports = [
+    ../user-interface.nix
+  ];
+}