nix/module/AmdCpu.nix

28 lines
661 B
Nix
Raw Normal View History

2024-06-25 04:04:39 +03:00
{ pkgs, lib, config, ... }: with lib; let
cfg = config.module.amd.cpu;
controlFile = "/sys/devices/system/cpu/cpufreq/boost";
enableCmd = "0";
disableCmd = "1";
in {
options = {
module.amd.cpu = {
2024-08-24 20:06:51 +03:00
enable = mkEnableOption "Enable AMD Cpu support.";
powersave = mkEnableOption "Enable AMD Cpu powersave.";
2024-06-25 04:04:39 +03:00
};
};
config = mkIf cfg.enable (mkMerge [
{
boot.kernelModules = [ "kvm-amd" ];
hardware.cpu.amd.updateMicrocode = mkDefault config.hardware.enableRedistributableFirmware;
}
2024-08-24 20:06:51 +03:00
(mkIf cfg.powersave {
2024-06-25 04:04:39 +03:00
module.powersave = {
enable = true;
cpu.boost = { inherit controlFile enableCmd disableCmd; };
};
})
]);
}