1{
2 config,
3 pkgs,
4 lib,
5 ...
6}:
7let
8 inherit (lib)
9 mkEnableOption
10 mkIf
11 mkPackageOption
12 ;
13
14 cfg = config.programs.corectrl;
15in
16{
17 imports = [
18 (lib.mkRenamedOptionModule
19 [ "programs" "corectrl" "gpuOverclock" "enable" ]
20 [ "hardware" "amdgpu" "overdrive" "enable" ]
21 )
22 (lib.mkRenamedOptionModule
23 [ "programs" "corectrl" "gpuOverclock" "ppfeaturemask" ]
24 [ "hardware" "amdgpu" "overdrive" "ppfeaturemask" ]
25 )
26 ];
27
28 options.programs.corectrl = {
29 enable = mkEnableOption ''
30 CoreCtrl, a tool to overclock amd graphics cards and processors.
31 Add your user to the corectrl group to run corectrl without needing to enter your password
32 '';
33
34 package = mkPackageOption pkgs "corectrl" {
35 extraDescription = "Useful for overriding the configuration options used for the package.";
36 };
37 };
38
39 config = mkIf cfg.enable {
40 environment.systemPackages = [ cfg.package ];
41
42 services.dbus.packages = [ cfg.package ];
43
44 users.groups.corectrl = { };
45
46 security.polkit.extraConfig = ''
47 polkit.addRule(function(action, subject) {
48 if ((action.id == "org.corectrl.helper.init" ||
49 action.id == "org.corectrl.helperkiller.init") &&
50 subject.local == true &&
51 subject.active == true &&
52 subject.isInGroup("corectrl")) {
53 return polkit.Result.YES;
54 }
55 });
56 '';
57 };
58
59 meta.maintainers = with lib.maintainers; [
60 artturin
61 Scrumplex
62 ];
63}