about summary refs log tree commit diff
path: root/modules/nixos-hardware/common/pc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/nixos-hardware/common/pc')
-rw-r--r--modules/nixos-hardware/common/pc/default.nix5
-rw-r--r--modules/nixos-hardware/common/pc/hdd/default.nix7
-rw-r--r--modules/nixos-hardware/common/pc/laptop/acpi_call.nix10
-rw-r--r--modules/nixos-hardware/common/pc/laptop/cpu-throttling-bug.nix38
-rw-r--r--modules/nixos-hardware/common/pc/laptop/default.nix13
-rw-r--r--modules/nixos-hardware/common/pc/laptop/hdd/default.nix8
l---------modules/nixos-hardware/common/pc/laptop/ssd1
-rw-r--r--modules/nixos-hardware/common/pc/ssd/default.nix7
8 files changed, 89 insertions, 0 deletions
diff --git a/modules/nixos-hardware/common/pc/default.nix b/modules/nixos-hardware/common/pc/default.nix
new file mode 100644
index 000000000000..0b498ff1d20e
--- /dev/null
+++ b/modules/nixos-hardware/common/pc/default.nix
@@ -0,0 +1,5 @@
+{ lib, ... }:
+
+{
+  services.xserver.libinput.enable = lib.mkDefault true;
+}
diff --git a/modules/nixos-hardware/common/pc/hdd/default.nix b/modules/nixos-hardware/common/pc/hdd/default.nix
new file mode 100644
index 000000000000..8cc5ada0deb9
--- /dev/null
+++ b/modules/nixos-hardware/common/pc/hdd/default.nix
@@ -0,0 +1,7 @@
+{ lib, ... }:
+
+{
+  boot.kernel.sysctl = {
+    "vm.swappiness" = lib.mkDefault 10;
+  };
+}
diff --git a/modules/nixos-hardware/common/pc/laptop/acpi_call.nix b/modules/nixos-hardware/common/pc/laptop/acpi_call.nix
new file mode 100644
index 000000000000..f8c17dcc4901
--- /dev/null
+++ b/modules/nixos-hardware/common/pc/laptop/acpi_call.nix
@@ -0,0 +1,10 @@
+# acpi_call makes tlp work for newer thinkpads
+
+{ config, ... }:
+
+{
+  boot = {
+    kernelModules = [ "acpi_call" ];
+    extraModulePackages = with config.boot.kernelPackages; [ acpi_call ];
+  };
+}
diff --git a/modules/nixos-hardware/common/pc/laptop/cpu-throttling-bug.nix b/modules/nixos-hardware/common/pc/laptop/cpu-throttling-bug.nix
new file mode 100644
index 000000000000..a44bb7225d0f
--- /dev/null
+++ b/modules/nixos-hardware/common/pc/laptop/cpu-throttling-bug.nix
@@ -0,0 +1,38 @@
+{ config, pkgs, ... }:
+{
+  # Temporary fix for cpu throttling issues visible in the kernel log
+  # (journalctl -k) by setting the same temperature limits used by
+  # Window$
+  # See https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues
+  systemd.services.cpu-throttling = {
+    enable = true;
+    description = "Sets the offset to 3 °C, so the new trip point is 97 °C";
+    documentation = [
+      "https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues"
+    ];
+    path = [ pkgs.msr-tools ];
+    script = "wrmsr -a 0x1a2 0x3000000";
+    serviceConfig = {
+      Type = "oneshot";
+    };
+    wantedBy = [
+      "timers.target"
+    ];
+  };
+
+  systemd.timers.cpu-throttling = {
+    enable = true;
+    description = "Set cpu heating limit to 97 °C";
+    documentation = [
+      "https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues"
+    ];
+    timerConfig = {
+      OnActiveSec = 60;
+      OnUnitActiveSec = 60;
+      Unit = "cpu-throttling.service";
+    };
+    wantedBy = [
+      "timers.target"
+    ];
+  };
+}
diff --git a/modules/nixos-hardware/common/pc/laptop/default.nix b/modules/nixos-hardware/common/pc/laptop/default.nix
new file mode 100644
index 000000000000..ebc4931dbc29
--- /dev/null
+++ b/modules/nixos-hardware/common/pc/laptop/default.nix
@@ -0,0 +1,13 @@
+{ config, lib, ... }:
+
+{
+  imports = [ ../. ];
+
+  # TODO: fix in NixOS/nixpkgs
+  # Disable governor set in hardware-configuration.nix,
+  # required when services.tlp.enable is true:
+  powerManagement.cpuFreqGovernor =
+    lib.mkIf config.services.tlp.enable (lib.mkForce null);
+
+  services.tlp.enable = lib.mkDefault true;
+}
diff --git a/modules/nixos-hardware/common/pc/laptop/hdd/default.nix b/modules/nixos-hardware/common/pc/laptop/hdd/default.nix
new file mode 100644
index 000000000000..63f29d458c29
--- /dev/null
+++ b/modules/nixos-hardware/common/pc/laptop/hdd/default.nix
@@ -0,0 +1,8 @@
+{ lib, ... }:
+
+{
+  imports = [ ../../hdd ];
+
+  # Hard disk protection if the laptop falls:
+  services.hdapsd.enable = lib.mkDefault true;
+}
diff --git a/modules/nixos-hardware/common/pc/laptop/ssd b/modules/nixos-hardware/common/pc/laptop/ssd
new file mode 120000
index 000000000000..e313834a4372
--- /dev/null
+++ b/modules/nixos-hardware/common/pc/laptop/ssd
@@ -0,0 +1 @@
+../ssd
\ No newline at end of file
diff --git a/modules/nixos-hardware/common/pc/ssd/default.nix b/modules/nixos-hardware/common/pc/ssd/default.nix
new file mode 100644
index 000000000000..af0b49568cd1
--- /dev/null
+++ b/modules/nixos-hardware/common/pc/ssd/default.nix
@@ -0,0 +1,7 @@
+{ lib, ... }:
+
+{
+  boot.kernel.sysctl = {
+    "vm.swappiness" = lib.mkDefault 1;
+  };
+}