This commit is contained in:
mjallen18
2026-03-18 20:59:27 -05:00
parent f4fd826c90
commit 5d1d3dc850
10 changed files with 52 additions and 239 deletions

View File

@@ -12,15 +12,13 @@ let
in
{
options.${namespace}.hardware.amd = {
enable = mkEnableOption "amd hardware config";
enable = mkEnableOption "AMD hardware configuration";
corectrl.enable = mkBoolOpt false "Enable Corectl";
corectrl.enable = mkBoolOpt false "Enable CoreCtrl GPU control";
corectrl.enablePolkit = mkBoolOpt false "Enable CoreCtrl polkit rules";
corectrl.polkitGroup = mkOpt types.str "wheel" "Group allowed to use CoreCtrl without password";
corectrl.enablePolkit = mkBoolOpt false "Enable Corectl Polkit";
corectrl.polkitGroup = mkOpt types.str "wheel" "Corectl Polkit Group";
lact.enable = mkBoolOpt false "Enable Lact daemon";
lact.enable = mkBoolOpt false "Enable LACT daemon (AMD GPU control)";
};
config = lib.mkIf cfg.enable {
@@ -29,26 +27,23 @@ in
"nct6775"
"k10temp"
];
kernelParams = [ (if cfg.enable then "amdgpu.ppfeaturemask=0xffffffff" else null) ];
kernelParams = [ "amdgpu.ppfeaturemask=0xffffffff" ];
};
# Configure programs
programs.corectrl = {
enable = cfg.corectrl.enable;
package = pkgs.corectrl;
};
# Configure environment
environment = {
# Force radv
variables = {
AMD_VULKAN_ICD = "RADV";
STEAM_FORCE_DESKTOPUI_SCALING = "1.0";
GDK_SCALE = "1";
};
systemPackages = lib.mkIf cfg.lact.enable [ pkgs.lact ];
};
# Configure polkit
security.polkit = lib.mkIf cfg.corectrl.enablePolkit {
extraConfig = ''
polkit.addRule(function(action, subject) {
@@ -63,13 +58,13 @@ in
'';
};
# nixpkg is broken so need to manually define
# k10temp is listed in kernelModules above, but the module doesn't always
# load early enough for sensors to be available. This service ensures it
# is loaded after multi-user.target.
systemd.services = {
load-k10temp = {
description = "Load k10temp manually cause it wont otherwise";
script = ''
${pkgs.kmod}/bin/modprobe k10temp
'';
description = "Load k10temp kernel module";
script = "${pkgs.kmod}/bin/modprobe k10temp";
wantedBy = [ "multi-user.target" ];
};
lactd = lib.mkIf cfg.lact.enable {
@@ -78,17 +73,10 @@ in
bash
lact
];
script = ''
lact daemon
'';
script = "lact daemon";
wantedBy = [ "multi-user.target" ];
after = [ "multi-user.target" ];
};
};
# Configure environment
environment = {
systemPackages = with pkgs; lib.mkIf cfg.lact.enable [ lact ];
};
};
}