about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-07-13 20:54:50 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-07-13 20:54:50 +0200
commitc9191bd797cde4b14bdcb2b9b5de45bbb29347ec (patch)
tree42b08e493ac5ac796a97a9abe2ebbad037803eb6
parentfmt (diff)
downloadnixos-config-c9191bd797cde4b14bdcb2b9b5de45bbb29347ec.tar.gz
nixos-config-c9191bd797cde4b14bdcb2b9b5de45bbb29347ec.tar.bz2
nixos-config-c9191bd797cde4b14bdcb2b9b5de45bbb29347ec.zip
Luna: Enable power-save module
-rw-r--r--hosts/luna/default.nix1
-rw-r--r--modules/power-save/default.nix31
2 files changed, 32 insertions, 0 deletions
diff --git a/hosts/luna/default.nix b/hosts/luna/default.nix
index 6194a71..27f02d6 100644
--- a/hosts/luna/default.nix
+++ b/hosts/luna/default.nix
@@ -3,6 +3,7 @@
   imports = [
     ./hardware.nix
 
+    ../../modules/power-save
     ../../modules/bluetooth
   ];
 
diff --git a/modules/power-save/default.nix b/modules/power-save/default.nix
new file mode 100644
index 0000000..569c6aa
--- /dev/null
+++ b/modules/power-save/default.nix
@@ -0,0 +1,31 @@
+{ config, pkgs, ... }:
+{
+
+  boot = {
+    kernelParams = [ "pcie_aspm.policy=powersave" ];
+    # blacklistedKernelModules = [ "uvcvideo" ];
+    extraModprobeConfig = ''
+      options snd_hda_intel power_save=1
+      options iwlwifi power_save=1 d0i3_disable=0 uapsd_disable=0
+      options iwldvm force_cam=0
+    '';
+    kernel.sysctl = {
+      "kernel.nmi_watchdog" = 0;
+      "vm.dirty_writeback_centisecs" = 6000;
+      "vm.laptop_mode" = 5;
+    };
+  };
+
+  services = {
+    udev.extraRules = ''
+      ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", RUN+="${pkgs.ethtool}/bin/ethtool -s %k wol d"
+      ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="${pkgs.iw}/bin/iw dev %k set power_save on"
+      ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"
+      ACTION=="add", SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"
+    '';
+    ## this leads to non-responsive input devices
+    # ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="auto"
+    # i2p.enable = pkgs.lib.mkForce false;
+    # tor.enable = pkgs.lib.mkForce false;
+  };
+}