summaryrefslogtreecommitdiffstats
path: root/modules/hardware/cpu.nix
blob: 8bf29232003cd6495cebe758ba9540c769721f0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
    config,
    options,
    lib,
    ...
}: let
    cpuConfig = config.modules.hardware.cpu;
    device = config.modules.device;
in {
    options.modules.hardware.cpu = {
        enable = lib.mkOption {
            type = lib.types.bool;
            default = true;
        };
    };

    config = lib.mkIf (cpuConfig.enable) (lib.mkMerge [
        {
            hardware.enableRedistributableFirmware = true;
            environment.systemPackages = [config.boot.kernelPackages.cpupower];
        }
        (lib.mkIf (device.cpu == "intel") {
            hardware.cpu.intel.updateMicrocode = true;
            boot.kernelModules = ["kvm-intel"];
        })
    ]);
}