tlp: enable on all hardwares
authorJulien Moutinho <julm+julm-nix@sourcephile.fr>
Wed, 12 Oct 2022 15:39:14 +0000 (17:39 +0200)
committerJulien Moutinho <julm+julm-nix@sourcephile.fr>
Wed, 12 Oct 2022 15:59:44 +0000 (17:59 +0200)
home-manager/options.nix
hosts/aubergine.nix
hosts/oignon.nix
hosts/oignon/hardware.nix
hosts/patate.nix
hosts/patate/hardware.nix
nixos/profiles/acpid.nix
nixos/profiles/hardware/X200.nix [new file with mode: 0644]
nixos/profiles/hardware/X201.nix [new file with mode: 0644]
nixos/profiles/hardware/thinkpad.nix
nixos/profiles/tlp.nix [new file with mode: 0644]

index e8dd0d33180631f7d9704caa07821cc6c2d7bbfa..6da5ae5c12b49e73ceafc314d6756d7b7717d040 100644 (file)
@@ -1,14 +1,6 @@
 { pkgs, lib, config, ... }:
 with builtins;
 {
-options.host = {
-  hardware = lib.mkOption {
-    type = with lib.types; listOf str;
-    default = filter (x: isString x && x != "") (split "[ \n]+" (readFile
-      "/sys/devices/virtual/dmi/id/product_name"));
-    description = "hardware";
-  };
-};
 config = {
   home.stateVersion = "20.09";
 };
index 69f704c30ce636c61d813fd02c0545a9d0cad3f3..ecf904c65c0fb929255f45f4c667d06cc696af32 100644 (file)
@@ -17,8 +17,6 @@ environment.etc.machine-id.source = aubergine/machine-id;
 
 home-manager.users.julm = {
   imports = [ ../homes/julm.nix ];
-  # /sys/devices/virtual/dmi/id/product_name
-  host.hardware = [ "apu6" ];
 };
 systemd.services.home-manager-julm.postStart = ''
   ${pkgs.nix}/bin/nix-env --delete-generations +1 --profile /nix/var/nix/profiles/per-user/julm/home-manager
index df27d3229a5e54c767f110f299996e611673329e..46f9ba49937ddf717af29ceb747231d17dd130b6 100644 (file)
@@ -20,7 +20,6 @@ boot.kernelParams = [ "mitigations=off" ];
 
 home-manager.users.julm = {
   imports = [ ../homes/julm.nix ];
-  host.hardware = [ "ThinkPad" "X201" ];
 };
 systemd.services.home-manager-julm.postStart = ''
   ${pkgs.nix}/bin/nix-env --delete-generations +1 --profile /nix/var/nix/profiles/per-user/julm/home-manager
index 43554b3794095d02f0a3c45c4b2fd90c1e767aee..59c80fc06b43ca2f17c4a66ecfa0260749cf7c6a 100644 (file)
@@ -1,8 +1,7 @@
 { config, lib, pkgs, hostName, ... }:
 {
 imports = [
-  ../../nixos/profiles/acpid.nix
-  ../../nixos/profiles/hardware/thinkpad.nix
+  ../../nixos/profiles/hardware/X201.nix
   ../../nixos/profiles/zfs.nix
   ../../nixos/profiles/zramSwap.nix
 ];
@@ -55,9 +54,6 @@ swapDevices = [
 networking.hostId = "ce53d0c3";
 
 boot.supportedFilesystems = [ "ntfs" "vfat" ];
-boot.extraModulePackages = [
-  #config.boot.kernelPackages.exfat-nofuse
-];
 
 powerManagement.powertop.enable = true;
 #services.fprintd.enable = true;
index 9a75972c6442528fb0acf9f6b38085fa7053f954..2bc92c1c8a02f76c8160dce29145bcb422978f18 100644 (file)
@@ -19,7 +19,6 @@ boot.kernelParams = [ "mitigations=off" ];
 
 home-manager.users.sevy = {
   imports = [ ../homes/sevy.nix ];
-  host.hardware = [ "ThinkPad" "X200" ];
 };
 systemd.services.home-manager-sevy.postStart = ''
   ${pkgs.nix}/bin/nix-env --delete-generations +1 --profile /nix/var/nix/profiles/per-user/sevy/home-manager
index e638776846285d5c0e9889dbbd9761ccd368f4b5..9fd138d305e2521664fe8c0cd7fbb7db42e155cc 100644 (file)
@@ -1,8 +1,7 @@
 { config, lib, pkgs, hostName, ... }:
 {
 imports = [
-  ../../nixos/profiles/acpid.nix
-  ../../nixos/profiles/hardware/thinkpad.nix
+  ../../nixos/profiles/hardware/X200.nix
   ../../nixos/profiles/zfs.nix
   ../../nixos/profiles/zramSwap.nix
 ];
index 488a1f4529bc6f9eecae4cb3ca974b29171c92c1..6ae17580f0b61c650cee8dc6eb8029c6e7be556d 100644 (file)
@@ -1,11 +1,6 @@
 { config, lib, pkgs, ... }:
 {
 hardware.acpilight.enable = true;
-boot.kernelModules = [ "msr" "acpi_cpufreq" ];
-systemd.services.acpid.postStart = ''
-  ${pkgs.acpi}/bin/acpi -a | grep -q 'Adapter .*: on-line' ||
-  ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave
-'';
 services.acpid = {
   enable = true;
   handlers = {
@@ -18,14 +13,5 @@ services.acpid = {
       action = "${pkgs.acpilight}/bin/xbacklight -inc 10";
     };
   };
-  acEventCommands = ''
-    vals=($1)
-    case ''${vals[3]} in
-      00000000) # unplugged
-        ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave;;
-      00000001) # plugged in
-        ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g ondemand;;
-    esac
-  '';
 };
 }
diff --git a/nixos/profiles/hardware/X200.nix b/nixos/profiles/hardware/X200.nix
new file mode 100644 (file)
index 0000000..c54f55b
--- /dev/null
@@ -0,0 +1,11 @@
+{ config, lib, pkgs, ... }:
+{
+imports = [
+  ./thinkpad.nix
+];
+
+# tp_smapi works on ThinkPads made before 2013. See compat table:
+# https://www.thinkwiki.org/wiki/Tp_smapi#Model-specific_status
+boot.kernelModules = [ "tp_smapi" ];
+boot.extraModulePackages = with config.boot.kernelPackages; [ tp_smapi ];
+}
diff --git a/nixos/profiles/hardware/X201.nix b/nixos/profiles/hardware/X201.nix
new file mode 100644 (file)
index 0000000..c54f55b
--- /dev/null
@@ -0,0 +1,11 @@
+{ config, lib, pkgs, ... }:
+{
+imports = [
+  ./thinkpad.nix
+];
+
+# tp_smapi works on ThinkPads made before 2013. See compat table:
+# https://www.thinkwiki.org/wiki/Tp_smapi#Model-specific_status
+boot.kernelModules = [ "tp_smapi" ];
+boot.extraModulePackages = with config.boot.kernelPackages; [ tp_smapi ];
+}
index f785f0b8abc76a184c7e1bdddc2d3527ec51f0bc..819c1e3dc9b1375d5743b18a5097a9c00aa6d799 100644 (file)
@@ -1,5 +1,9 @@
 { config, lib, pkgs, ... }:
 {
+imports = [
+  ../acpid.nix
+  ../tlp.nix
+];
 boot.cleanTmpDir = true;
 boot.tmpOnTmpfs = true;
 
diff --git a/nixos/profiles/tlp.nix b/nixos/profiles/tlp.nix
new file mode 100644 (file)
index 0000000..8dccace
--- /dev/null
@@ -0,0 +1,11 @@
+{ config, lib, pkgs, ... }:
+with lib;
+{
+services.tlp = {
+  enable = true;
+  settings = {
+    CPU_SCALING_GOVERNOR_ON_AC = "ondemand";
+    CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
+  };
+};
+}