{
  pkgs,
  lib,
  config,
  ...
}:
with lib;
{
  imports = [
    ../acpid.nix
    ../tlp.nix
  ];

  nixpkgs.hostPlatform = {
    system = "x86_64-linux";
    config = "x86_64-unknown-linux-gnu";
  };

  boot.kernelModules = [ "kvm-intel" ];
  # https://bugzilla.kernel.org/show_bug.cgi?id=110941
  boot.initrd.availableKernelModules = [
    "ahci"
    "drbg"
    "ehci_pci"
    "gf128mul"
    "hmac"
    "sd_mod"
    # tp_smapi works on ThinkPads made before 2013. See compat table:
    # https://www.thinkwiki.org/wiki/Tp_smapi#Model-specific_status
    "tp_smapi"
  ];
  boot.extraModulePackages = with config.boot.kernelPackages; [
    tp_smapi
  ];
  boot.kernelParams = [ "intel_pstate=no_hwp" ];

  environment.systemPackages = [
    pkgs.geteltorito
  ];

  hardware.cpu.intel.updateMicrocode = mkDefault config.hardware.enableRedistributableFirmware;
  hardware.graphics.extraPackages = [
    pkgs.intel-media-driver # LIBVA_DRIVER_NAME=iHD
    # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
    (
      if (versionOlder (versions.majorMinor version) "23.11") then
        pkgs.vaapiIntel
      else
        pkgs.intel-vaapi-driver
    )
    pkgs.libvdpau-va-gl
    pkgs.vaapiVdpau
  ];
  hardware.trackpoint.enable = mkDefault true;
  hardware.trackpoint.emulateWheel = mkDefault config.hardware.trackpoint.enable;

  services.thinkfan = {
    enable = true;
    smartSupport = true;
    levels = [
      [
        0
        0
        57
      ]
      [
        1
        56
        60
      ]
      [
        2
        59
        63
      ]
      [
        3
        62
        65
      ]
      [
        4
        64
        67
      ]
      [
        5
        66
        72
      ]
      [
        6
        71
        78
      ]
      [
        7
        77
        82
      ]
      [
        127
        81
        32767
      ]
    ];
  };
  services.upower.enable = true;
  services.libinput.enable = mkDefault true;

  # No pstore backend available on this system.
  systemd.services.mount-pstore.enable = false;
}