Skip to content

Commit

Permalink
modules/hardware/thinkpad: add selection option for CPU type
Browse files Browse the repository at this point in the history
Newer thinkpads also come with AMD, in which case we don’t want to
enable intel-specfic options.
  • Loading branch information
Profpatsch committed Oct 23, 2024
1 parent 3b0d521 commit a08d7ba
Showing 1 changed file with 46 additions and 31 deletions.
77 changes: 46 additions & 31 deletions modules/hardware/thinkpad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,53 @@ in
{
options.vuizvui.hardware.thinkpad = {
enable = lib.mkEnableOption "thinkpad support";
};

config = lib.mkIf cfg.enable {

# We need to update the Intel microcode on every update,
# otherwise there can be problems with newers kernels.
hardware.cpu.intel.updateMicrocode = lib.mkDefault true;

# read acpi stats (e.g. battery)
environment.systemPackages = [ pkgs.acpi ];

# for wifi
hardware.enableRedistributableFirmware = lib.mkDefault true;

hardware.trackpoint = lib.mkDefault {
enable = true;
emulateWheel = true;
speed = 250;
sensitivity = 140;
};

# TLP Linux Advanced Power Management
services.tlp.enable = lib.mkDefault true;
boot = {
# acpi_call is required for some tlp features, e.g. discharge/recalibrate
kernelModules = [
"acpi_call"
];

extraModulePackages = [
config.boot.kernelPackages.acpi_call
];
cpuType = lib.mkOption {
type = lib.types.enum [ "intel" "amd" ];
default = "intel";
description = "The CPU type of the ThinkPad";
};
};

config = lib.mkIf cfg.enable (lib.mkMerge [
(lib.mkIf (cfg.cpuType == "intel") {
# We need to update the Intel microcode on every update,
# otherwise there can be problems with newer kernels.
hardware.cpu.intel.updateMicrocode = lib.mkDefault true;

})
(lib.mkIf (cfg.cpuType == "amd") {
# We need to update the AMD microcode on every update,
# otherwise there can be problems with newer kernels.
hardware.cpu.amd.updateMicrocode = lib.mkDefault true;
})
{
# read acpi stats (e.g. battery)
environment.systemPackages = [ pkgs.acpi ];

# for wifi & cpu microcode (amd)
hardware.enableRedistributableFirmware = lib.mkDefault true;

hardware.trackpoint = lib.mkDefault {
enable = true;
emulateWheel = true;
speed = 250;
sensitivity = 140;
};

# TLP Linux Advanced Power Management
services.tlp.enable = lib.mkDefault true;

boot = {
# acpi_call is required for some tlp features, e.g. discharge/recalibrate
kernelModules = [
"acpi_call"
];

extraModulePackages = [
config.boot.kernelPackages.acpi_call
];
};
}
]);
}

0 comments on commit a08d7ba

Please sign in to comment.