about summary refs log tree commit diff
path: root/modules/nixos-hardware/lenovo
diff options
context:
space:
mode:
Diffstat (limited to 'modules/nixos-hardware/lenovo')
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/default.nix3
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/e495/default.nix11
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/l13/default.nix10
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/p53/default.nix10
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/t420/default.nix9
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/t430/default.nix1
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/t440s/default.nix14
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/t460s/default.nix5
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/t470s/default.nix9
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/t480s/default.nix3
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/t490/default.nix31
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/t490/t490-profile-set.conf107
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/t495/default.nix16
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/x1-extreme/default.nix8
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/x1-extreme/gen2/default.nix48
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/x1/6th-gen/default.nix28
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/x250/default.nix1
-rw-r--r--modules/nixos-hardware/lenovo/thinkpad/x280/default.nix12
18 files changed, 300 insertions, 26 deletions
diff --git a/modules/nixos-hardware/lenovo/thinkpad/default.nix b/modules/nixos-hardware/lenovo/thinkpad/default.nix
index ff22639b4fdc..99d4937e49c7 100644
--- a/modules/nixos-hardware/lenovo/thinkpad/default.nix
+++ b/modules/nixos-hardware/lenovo/thinkpad/default.nix
@@ -1,9 +1,10 @@
-{ lib, pkgs, ... }:
+{ config, lib, pkgs, ... }:
 
 {
   imports = [ ../../common/pc/laptop ];
 
   hardware.trackpoint.enable = lib.mkDefault true;
+  hardware.trackpoint.emulateWheel = lib.mkDefault config.hardware.trackpoint.enable;
 
   # Fingerprint reader: login and unlock with fingerprint (if you add one with `fprintd-enroll`)
   # services.fprintd.enable = true;
diff --git a/modules/nixos-hardware/lenovo/thinkpad/e495/default.nix b/modules/nixos-hardware/lenovo/thinkpad/e495/default.nix
new file mode 100644
index 000000000000..51ddb5cfd010
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/e495/default.nix
@@ -0,0 +1,11 @@
+{ config, lib, pkgs, ... }:
+
+{
+  imports = [
+    ../.
+    ../../../common/cpu/amd
+  ];
+
+  # see https://github.com/NixOS/nixpkgs/issues/69289
+  boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.2") pkgs.linuxPackages_latest;
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/l13/default.nix b/modules/nixos-hardware/lenovo/thinkpad/l13/default.nix
new file mode 100644
index 000000000000..3c09f5091ed8
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/l13/default.nix
@@ -0,0 +1,10 @@
+{ nixos, lib, pkgs, config, stdenv, ... }:
+{
+  imports = [
+    ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
+    ../.
+  ];
+
+  services.throttled.enable = lib.mkDefault true;
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/p53/default.nix b/modules/nixos-hardware/lenovo/thinkpad/p53/default.nix
new file mode 100644
index 000000000000..a499d5c2d51e
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/p53/default.nix
@@ -0,0 +1,10 @@
+{ nixos, pkgs, lib, config, stdenv, ... }:
+{
+  imports = [
+    ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
+    ../.
+  ];
+
+  services.throttled.enable = lib.mkDefault true;
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/t420/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t420/default.nix
new file mode 100644
index 000000000000..5d3efe831c96
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/t420/default.nix
@@ -0,0 +1,9 @@
+{ config, lib, pkgs, ... }:
+
+{
+  imports = [
+    ../.
+    ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
+  ];
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/t430/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t430/default.nix
index 09cee74942e9..bdad1be9878a 100644
--- a/modules/nixos-hardware/lenovo/thinkpad/t430/default.nix
+++ b/modules/nixos-hardware/lenovo/thinkpad/t430/default.nix
@@ -4,6 +4,7 @@
   imports = [
     ../.
     ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
   ];
 
   boot = {
diff --git a/modules/nixos-hardware/lenovo/thinkpad/t440s/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t440s/default.nix
new file mode 100644
index 000000000000..c40ad90f9b3d
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/t440s/default.nix
@@ -0,0 +1,14 @@
+{ config, lib, pkgs, ... }:
+
+{
+  imports = [
+    ../.
+    ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
+  ];
+
+  boot = {
+    # TODO: probably enable tcsd? Is this line necessary?
+    kernelModules = [ "tpm-rng" ];
+  };
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/t460s/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t460s/default.nix
index 41558a35b7f6..e62337171b9a 100644
--- a/modules/nixos-hardware/lenovo/thinkpad/t460s/default.nix
+++ b/modules/nixos-hardware/lenovo/thinkpad/t460s/default.nix
@@ -3,10 +3,7 @@
 {
   imports = [
     ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
     ../.
   ];
-
-  # TODO: boot loader
-  boot.loader.systemd-boot.enable = lib.mkDefault true;
-  boot.loader.efi.canTouchEfiVariables = lib.mkDefault true;
 }
diff --git a/modules/nixos-hardware/lenovo/thinkpad/t470s/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t470s/default.nix
new file mode 100644
index 000000000000..e62337171b9a
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/t470s/default.nix
@@ -0,0 +1,9 @@
+{ config, lib, pkgs, ... }:
+
+{
+  imports = [
+    ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
+    ../.
+  ];
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/t480s/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t480s/default.nix
index 3e079d5fb060..1a14afa6b5e4 100644
--- a/modules/nixos-hardware/lenovo/thinkpad/t480s/default.nix
+++ b/modules/nixos-hardware/lenovo/thinkpad/t480s/default.nix
@@ -4,7 +4,8 @@
   imports = [
     ../../../common/cpu/intel
     ../../../common/pc/laptop/acpi_call.nix
-    ../../../common/pc/laptop/cpu-throttling-bug.nix
     ../.
   ];
+
+  services.throttled.enable = lib.mkDefault true;
 }
diff --git a/modules/nixos-hardware/lenovo/thinkpad/t490/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t490/default.nix
new file mode 100644
index 000000000000..3578da66c73d
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/t490/default.nix
@@ -0,0 +1,31 @@
+{ nixos, lib, pkgs, config, stdenv, ... }:
+{
+  imports = [
+    ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
+    ../.
+  ];
+
+  services = {
+    # This fixes the pulseaudio profiles of the Thinkpad T490.
+    # The laptop contains a single audio card with 5 sub-devices. Default pulseaudio only offers a single sink
+    # which can only be switched between speaker/HDMI via a manual profile change.
+    # This configures a profile set for pulseaudio which offers multiple sinks corresponding to the
+    # speaker + 4 HDMI ports. This allows the user to play audio streams on the speaker and any of the 4 HDMI/USB-C
+    # ports at the same time.
+    udev.extraRules = let
+      t490ProfileSet = ./t490-profile-set.conf;
+    in ''
+    SUBSYSTEM!="sound", GOTO="pulseaudio_end"
+    ACTION!="change", GOTO="pulseaudio_end"
+    KERNEL!="card*", GOTO="pulseaudio_end"
+
+    # Lenovo T490
+    ATTRS{vendor}=="0x8086" ATTRS{device}=="0x9dc8" ATTRS{subsystem_vendor}=="0x17aa", ATTRS{subsystem_device}=="0x2279", ENV{PULSE_PROFILE_SET}="${t490ProfileSet}"
+
+    LABEL="pulseaudio_end"
+    '';
+    
+    throttled.enable = lib.mkDefault true;
+  };
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/t490/t490-profile-set.conf b/modules/nixos-hardware/lenovo/thinkpad/t490/t490-profile-set.conf
new file mode 100644
index 000000000000..98f8f0318de1
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/t490/t490-profile-set.conf
@@ -0,0 +1,107 @@
+[Profile speaker+hdmi-stereo]
+description = Speaker + HDMI Stereo
+output-mappings = analog-stereo hdmi-stereo hdmi-stereo-extra1 hdmi-stereo-extra2
+input-mappings = analog-stereo
+
+[Mapping analog-stereo]
+device-strings = front:%f
+channel-map = left,right
+paths-output = analog-output analog-output-lineout analog-output-speaker analog-output-headphones analog-output-headphones-2
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic analog-input-headset-mic
+priority = 15
+
+[Mapping hdmi-stereo]
+description = Stereo (HDMI)
+device-strings = hdmi:%f
+paths-output = hdmi-output-0
+channel-map = left,right
+priority = 6
+direction = output
+
+[Mapping hdmi-stereo-extra1]
+description = Stereo (HDMI 2)
+device-strings = hdmi:%f,1
+paths-output = hdmi-output-1
+channel-map = left,right
+priority = 8
+direction = output
+
+[Mapping hdmi-stereo-extra2]
+description = Stereo (HDMI 3)
+device-strings = hdmi:%f,2
+paths-output = hdmi-output-2
+channel-map = left,right
+priority = 6
+direction = output
+
+[Profile speaker+hdmi-surround]
+description = Speaker + HDMI 5.1
+output-mappings = analog-stereo hdmi-surround hdmi-surround-extra1 hdmi-surround-extra2
+input-mappings = analog-stereo
+
+[Mapping analog-stereo]
+device-strings = front:%f
+channel-map = left,right
+paths-output = analog-output analog-output-lineout analog-output-speaker analog-output-headphones analog-output-headphones-2
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic analog-input-headset-mic
+priority = 15
+
+[Mapping hdmi-surround]
+description = Digital Surround 5.1 (HDMI)
+device-strings = hdmi:%f
+paths-output = hdmi-output-0
+channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe
+priority = 6
+direction = output
+
+[Mapping hdmi-surround-extra1]
+description = Digital Surround 5.1 (HDMI 2)
+device-strings = hdmi:%f,1
+paths-output = hdmi-output-1
+channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe
+priority = 8
+direction = output
+
+[Mapping hdmi-surround-extra2]
+description = Digital Surround 5.1 (HDMI 3)
+device-strings = hdmi:%f,2
+paths-output = hdmi-output-2
+channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe
+priority = 6
+direction = output
+
+[Profile speaker+hdmi-surround71]
+description = Speaker + HDMI 7.1
+output-mappings = analog-stereo hdmi-surround71 hdmi-surround71-extra1 hdmi-surround71-extra2
+input-mappings = analog-stereo
+
+[Mapping analog-stereo]
+device-strings = front:%f
+channel-map = left,right
+paths-output = analog-output analog-output-lineout analog-output-speaker analog-output-headphones analog-output-headphones-2
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic analog-input-headset-mic
+priority = 15
+
+[Mapping hdmi-surround71]
+description = Digital Surround 7.1 (HDMI)
+device-strings = hdmi:%f
+paths-output = hdmi-output-0
+channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right
+priority = 6
+direction = output
+
+[Mapping hdmi-surround71-extra1]
+description = Digital Surround 7.1 (HDMI 2)
+device-strings = hdmi:%f,1
+paths-output = hdmi-output-1
+channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right
+priority = 8
+direction = output
+
+[Mapping hdmi-surround71-extra2]
+description = Digital Surround 7.1 (HDMI 3)
+device-strings = hdmi:%f,2
+paths-output = hdmi-output-2
+channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right
+priority = 6
+direction = output
diff --git a/modules/nixos-hardware/lenovo/thinkpad/t495/default.nix b/modules/nixos-hardware/lenovo/thinkpad/t495/default.nix
new file mode 100644
index 000000000000..64957e6e06c7
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/t495/default.nix
@@ -0,0 +1,16 @@
+{ config, lib, pkgs, ... }:
+
+{
+  imports = [
+    ../.
+    ../../../common/cpu/amd
+    ../../../common/pc/laptop/acpi_call.nix
+  ];
+
+  # Force use of the thinkpad_acpi driver for backlight control.
+  # This allows the backlight save/load systemd service to work.
+  boot.kernelParams = [ "acpi_backlight=native" ];
+
+  # see https://github.com/NixOS/nixpkgs/issues/69289
+  boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.2") pkgs.linuxPackages_latest;
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/x1-extreme/default.nix b/modules/nixos-hardware/lenovo/thinkpad/x1-extreme/default.nix
new file mode 100644
index 000000000000..09a0ec1700a5
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/x1-extreme/default.nix
@@ -0,0 +1,8 @@
+{
+  imports = [
+    ../.
+    ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
+    ../../../common/pc/laptop/ssd
+  ];
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/x1-extreme/gen2/default.nix b/modules/nixos-hardware/lenovo/thinkpad/x1-extreme/gen2/default.nix
new file mode 100644
index 000000000000..6b0ebbd5d1e3
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/x1-extreme/gen2/default.nix
@@ -0,0 +1,48 @@
+{ config, lib, ... }:
+
+with lib;
+
+{
+  imports = [
+    ../.
+  ];
+
+  # Fixes an issue with incorrect battery reporting. See
+  # https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Extreme_(Gen_2)#Invalid_Stats_Workaround
+  boot.initrd.availableKernelModules = [ "battery" ];
+
+  # New ThinkPads have a different TrackPoint manufacturer/name.
+  # See also https://certification.ubuntu.com/catalog/component/input/5313/input%3ATPPS/2ElanTrackPoint/
+  hardware.trackpoint.device = "TPPS/2 Elan TrackPoint";
+
+  # Since the HDMI port is connected to the NVIDIA card.
+  hardware.bumblebee.connectDisplay = true;
+
+  nixpkgs.overlays = [
+    (self: super: {
+      bumblebee = super.bumblebee.override {
+        extraNvidiaDeviceOptions = ''
+          Option "AllowEmptyInitialConfiguration"
+        '';
+      };
+    })
+  ];
+
+  services.xserver = mkMerge [
+    {
+      # Set the right DPI. xdpyinfo says the screen is 508×285 mm but
+      # it actually is 344×193 mm.
+      monitorSection = ''
+        DisplaySize 344 193
+      '';
+    }
+
+    # To support intel-virtual-output when using Bumblebee.
+    (mkIf config.hardware.bumblebee.enable {
+      deviceSection = ''Option "VirtualHeads" "1"'';
+      videoDrivers = [ "intel" ];
+    })
+  ];
+
+  services.throttled.enable = lib.mkDefault true;
+}
diff --git a/modules/nixos-hardware/lenovo/thinkpad/x1/6th-gen/default.nix b/modules/nixos-hardware/lenovo/thinkpad/x1/6th-gen/default.nix
index 9584bc744571..00446b8c278b 100644
--- a/modules/nixos-hardware/lenovo/thinkpad/x1/6th-gen/default.nix
+++ b/modules/nixos-hardware/lenovo/thinkpad/x1/6th-gen/default.nix
@@ -2,31 +2,19 @@
 # standing with kernel 4.6.11 is the following wiki page:
 # https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6). The
 # TrackPoint and TouchPad issues there seem to have been fixed already.
-
-{ config, pkgs, ... }:
+#
+# Enable the lower-power S3 suspend state by upgrading the BIOS to version >= 1.30,
+# then manually selecting Linux in the power management section.
+{ config, pkgs, lib, ... }:
 {
   imports = [
     ../.
     ../../../../common/pc/laptop/acpi_call.nix
-    ../../../../common/pc/laptop/cpu-throttling-bug.nix
   ];
 
-  # See https://linrunner.de/en/tlp/docs/tlp-faq.html#battery
-  services.tlp.extraConfig = ''
-    START_CHARGE_THRESH_BAT0=75
-    STOP_CHARGE_THRESH_BAT0=80
-    CPU_SCALING_GOVERNOR_ON_BAT=powersave
-    ENERGY_PERF_POLICY_ON_BAT=powersave
-  '';
+  # New ThinkPads have a different TrackPoint manufacturer/name.
+  # See also https://certification.ubuntu.com/catalog/component/input/5313/input%3ATPPS/2ElanTrackPoint/
+  hardware.trackpoint.device = "TPPS/2 Elan TrackPoint";
 
-  # Enable S3 suspend state: you have to manually follow the
-  # instructions shown here: https://delta-xi.net/#056 in order to
-  # produce the ACPI patched table. Put the CPIO archive in /boot and
-  # then enable the following lines
-  # boot.kernelParams = [
-  #   "mem_sleep_default=deep"
-  # ];
-  # boot.initrd.prepend = [
-  #   "${/boot/acpi_override}"
-  # ];
+  services.throttled.enable = lib.mkDefault true;
 }
diff --git a/modules/nixos-hardware/lenovo/thinkpad/x250/default.nix b/modules/nixos-hardware/lenovo/thinkpad/x250/default.nix
index 870d9a857742..55ae2096342e 100644
--- a/modules/nixos-hardware/lenovo/thinkpad/x250/default.nix
+++ b/modules/nixos-hardware/lenovo/thinkpad/x250/default.nix
@@ -2,5 +2,6 @@
   imports = [
     ../.
     ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
   ];
 }
diff --git a/modules/nixos-hardware/lenovo/thinkpad/x280/default.nix b/modules/nixos-hardware/lenovo/thinkpad/x280/default.nix
new file mode 100644
index 000000000000..a9423e547321
--- /dev/null
+++ b/modules/nixos-hardware/lenovo/thinkpad/x280/default.nix
@@ -0,0 +1,12 @@
+{ config, pkgs, lib, ... }:
+
+{
+  imports = [
+    ../.
+    ../../../common/cpu/intel
+    ../../../common/pc/laptop/acpi_call.nix
+    ../../../common/pc/laptop/ssd/default.nix
+  ];
+
+  services.throttled.enable = lib.mkDefault true;
+}