1 { config, pkgs, lib, ... }:
3 cfg = config.programs.corectrl;
6 options.programs.corectrl = {
7 enable = lib.mkEnableOption ''
8 CoreCtrl, a tool to overclock amd graphics cards and processors.
9 Add your user to the corectrl group to run corectrl without needing to enter your password
12 package = lib.mkPackageOption pkgs "corectrl" {
13 extraDescription = "Useful for overriding the configuration options used for the package.";
17 enable = lib.mkEnableOption ''
20 ppfeaturemask = lib.mkOption {
22 default = "0xfffd7fff";
23 example = "0xffffffff";
25 Sets the `amdgpu.ppfeaturemask` kernel option.
26 In particular, it is used here to set the overdrive bit.
27 Default is `0xfffd7fff` as it is less likely to cause flicker issues.
28 Setting it to `0xffffffff` enables all features.
34 config = lib.mkIf cfg.enable (lib.mkMerge [
36 environment.systemPackages = [ cfg.package ];
38 services.dbus.packages = [ cfg.package ];
40 users.groups.corectrl = { };
42 security.polkit.extraConfig = ''
43 polkit.addRule(function(action, subject) {
44 if ((action.id == "org.corectrl.helper.init" ||
45 action.id == "org.corectrl.helperkiller.init") &&
46 subject.local == true &&
47 subject.active == true &&
48 subject.isInGroup("corectrl")) {
49 return polkit.Result.YES;
55 (lib.mkIf cfg.gpuOverclock.enable {
56 # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_shared.h#n169
58 boot.kernelParams = [ "amdgpu.ppfeaturemask=${cfg.gpuOverclock.ppfeaturemask}" ];
62 meta.maintainers = with lib.maintainers; [ artturin ];