mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-05 17:27:50 +00:00
[Hardware/AMD] Add CPU configuration
This commit is contained in:
parent
0b3ba6cea3
commit
b59e72d549
2 changed files with 38 additions and 0 deletions
35
hardware/amd/cpu.nix
Normal file
35
hardware/amd/cpu.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{config, pkgs, lib, ...}:
|
||||
with lib;
|
||||
let
|
||||
generalCfg = config.aviallon.general;
|
||||
cpuIsZen = ! isNull (builtins.match "znver[0-9]" generalCfg.cpuArch);
|
||||
in {
|
||||
config = mkIf (generalCfg.cpuVendor == "amd") {
|
||||
boot.kernel.sysctl = {
|
||||
|
||||
# Why: https://www.phoronix.com/news/Ryzen-Segv-Response
|
||||
# Workaround: https://forums.gentoo.org/viewtopic-p-2605135.html#2605135
|
||||
"kernel.randomize_va_space" = mkIf (generalCfg.cpuArch == "znver1" ) (warn "Disable Adress Space Layout Randomization on Ryzen 1 CPU" 0);
|
||||
};
|
||||
|
||||
aviallon.boot.cmdline = {
|
||||
"amd_pstate" = "passive";
|
||||
} // optionalAttrs (generalCfg.cpuArch == "znver2") {
|
||||
# Required for Zen 2
|
||||
"amd_pstate.shared_memory" = 1;
|
||||
};
|
||||
|
||||
boot.extraModulePackages = with config.boot.kernelPackages; []
|
||||
++ optional cpuIsZen (info "enable zenpower for Ryzen CPU" zenpower)
|
||||
;
|
||||
|
||||
boot.kernelModules = []
|
||||
++ optional cpuIsZen "zenpower"
|
||||
;
|
||||
|
||||
boot.blacklistedKernelModules = []
|
||||
++ optional cpuIsZen "k10-temp" # Superseded by zenpower
|
||||
;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -16,6 +16,9 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
./cpu.nix
|
||||
];
|
||||
|
||||
config = mkIf (cfg.enable) {
|
||||
boot.initrd.kernelModules = [ "amdgpu" ];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue