15 cfg = config.programs.corectrl;
18 options.programs.corectrl = {
19 enable = mkEnableOption ''
20 CoreCtrl, a tool to overclock amd graphics cards and processors.
21 Add your user to the corectrl group to run corectrl without needing to enter your password
24 package = mkPackageOption pkgs "corectrl" {
25 extraDescription = "Useful for overriding the configuration options used for the package.";
29 enable = mkEnableOption ''
32 ppfeaturemask = mkOption {
34 default = "0xfffd7fff";
35 example = "0xffffffff";
37 Sets the `amdgpu.ppfeaturemask` kernel option.
38 In particular, it is used here to set the overdrive bit.
39 Default is `0xfffd7fff` as it is less likely to cause flicker issues.
40 Setting it to `0xffffffff` enables all features.
46 config = mkIf cfg.enable {
47 environment.systemPackages = [ cfg.package ];
49 services.dbus.packages = [ cfg.package ];
51 users.groups.corectrl = { };
53 security.polkit.extraConfig = ''
54 polkit.addRule(function(action, subject) {
55 if ((action.id == "org.corectrl.helper.init" ||
56 action.id == "org.corectrl.helperkiller.init") &&
57 subject.local == true &&
58 subject.active == true &&
59 subject.isInGroup("corectrl")) {
60 return polkit.Result.YES;
65 # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_shared.h#n169
67 boot.kernelParams = mkIf cfg.gpuOverclock.enable [
68 "amdgpu.ppfeaturemask=${cfg.gpuOverclock.ppfeaturemask}"
72 meta.maintainers = with lib.maintainers; [