nixpkgs/nixos/modules/hardware/corectrl.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
2.0 KiB
Nix
Raw Normal View History

2021-06-10 03:50:51 +00:00
{ config, pkgs, lib, ... }:
let
cfg = config.programs.corectrl;
in
{
options.programs.corectrl = {
enable = lib.mkEnableOption ''
CoreCtrl, a tool to overclock amd graphics cards and processors.
2021-06-10 03:50:51 +00:00
Add your user to the corectrl group to run corectrl without needing to enter your password
'';
package = lib.mkPackageOption pkgs "corectrl" {
extraDescription = "Useful for overriding the configuration options used for the package.";
};
2021-06-10 03:50:51 +00:00
gpuOverclock = {
enable = lib.mkEnableOption ''
GPU overclocking
2021-06-10 03:50:51 +00:00
'';
ppfeaturemask = lib.mkOption {
type = lib.types.str;
2021-06-10 03:50:51 +00:00
default = "0xfffd7fff";
example = "0xffffffff";
description = ''
Sets the `amdgpu.ppfeaturemask` kernel option.
In particular, it is used here to set the overdrive bit.
Default is `0xfffd7fff` as it is less likely to cause flicker issues.
Setting it to `0xffffffff` enables all features.
'';
};
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
2021-06-10 03:50:51 +00:00
{
environment.systemPackages = [ cfg.package ];
2021-06-10 03:50:51 +00:00
services.dbus.packages = [ cfg.package ];
2021-06-10 03:50:51 +00:00
users.groups.corectrl = { };
security.polkit.extraConfig = ''
polkit.addRule(function(action, subject) {
if ((action.id == "org.corectrl.helper.init" ||
action.id == "org.corectrl.helperkiller.init") &&
subject.local == true &&
subject.active == true &&
subject.isInGroup("corectrl")) {
return polkit.Result.YES;
}
});
'';
}
(lib.mkIf cfg.gpuOverclock.enable {
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_shared.h#n169
# The overdrive bit
boot.kernelParams = [ "amdgpu.ppfeaturemask=${cfg.gpuOverclock.ppfeaturemask}" ];
})
]);
meta.maintainers = with lib.maintainers; [ artturin ];
}