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
1.5 KiB
Nix
Raw Normal View History

{
config,
pkgs,
lib,
...
}:
2021-06-10 06:50:51 +03:00
let
inherit (lib)
mkEnableOption
mkIf
mkPackageOption
;
2021-06-10 06:50:51 +03:00
cfg = config.programs.corectrl;
in
{
imports = [
(lib.mkRenamedOptionModule
[ "programs" "corectrl" "gpuOverclock" "enable" ]
[ "hardware" "amdgpu" "overdrive" "enable" ]
)
(lib.mkRenamedOptionModule
[ "programs" "corectrl" "gpuOverclock" "ppfeaturemask" ]
[ "hardware" "amdgpu" "overdrive" "ppfeaturemask" ]
)
];
2021-06-10 06:50:51 +03:00
options.programs.corectrl = {
enable = mkEnableOption ''
CoreCtrl, a tool to overclock amd graphics cards and processors.
2021-06-10 06:50:51 +03:00
Add your user to the corectrl group to run corectrl without needing to enter your password
'';
package = mkPackageOption pkgs "corectrl" {
extraDescription = "Useful for overriding the configuration options used for the package.";
};
2021-06-10 06:50:51 +03:00
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
2021-06-10 06:50:51 +03:00
services.dbus.packages = [ cfg.package ];
2021-06-10 06:50:51 +03:00
users.groups.corectrl = { };
2021-06-10 06:50:51 +03:00
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;
}
});
'';
};
2021-06-10 06:50:51 +03:00
meta.maintainers = with lib.maintainers; [
artturin
Scrumplex
];
2021-06-10 06:50:51 +03:00
}