Merge pull request #126439 from Artturin/add-corectrl-module

nixos/corectrl: init module

authored by

Anderson Torres and committed by
GitHub
0b37436b e1484355

+63
+62
nixos/modules/hardware/corectrl.nix
··· 1 + { config, pkgs, lib, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.programs.corectrl; 7 + in 8 + { 9 + options.programs.corectrl = { 10 + enable = mkEnableOption '' 11 + A tool to overclock amd graphics cards and processors. 12 + Add your user to the corectrl group to run corectrl without needing to enter your password 13 + ''; 14 + 15 + gpuOverclock = { 16 + enable = mkEnableOption '' 17 + true 18 + ''; 19 + ppfeaturemask = mkOption { 20 + type = types.str; 21 + default = "0xfffd7fff"; 22 + example = "0xffffffff"; 23 + description = '' 24 + Sets the `amdgpu.ppfeaturemask` kernel option. 25 + In particular, it is used here to set the overdrive bit. 26 + Default is `0xfffd7fff` as it is less likely to cause flicker issues. 27 + Setting it to `0xffffffff` enables all features. 28 + ''; 29 + }; 30 + }; 31 + }; 32 + 33 + config = mkIf cfg.enable (lib.mkMerge [ 34 + { 35 + environment.systemPackages = [ pkgs.corectrl ]; 36 + 37 + services.dbus.packages = [ pkgs.corectrl ]; 38 + 39 + users.groups.corectrl = { }; 40 + 41 + security.polkit.extraConfig = '' 42 + polkit.addRule(function(action, subject) { 43 + if ((action.id == "org.corectrl.helper.init" || 44 + action.id == "org.corectrl.helperkiller.init") && 45 + subject.local == true && 46 + subject.active == true && 47 + subject.isInGroup("corectrl")) { 48 + return polkit.Result.YES; 49 + } 50 + }); 51 + ''; 52 + } 53 + 54 + (lib.mkIf cfg.gpuOverclock.enable { 55 + # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_shared.h#n169 56 + # The overdrive bit 57 + boot.kernelParams = [ "amdgpu.ppfeaturemask=${cfg.gpuOverclock.ppfeaturemask}" ]; 58 + }) 59 + ]); 60 + 61 + meta.maintainers = with lib.maintainers; [ artturin ]; 62 + }
+1
nixos/modules/module-list.nix
··· 44 44 ./hardware/ckb-next.nix 45 45 ./hardware/cpu/amd-microcode.nix 46 46 ./hardware/cpu/intel-microcode.nix 47 + ./hardware/corectrl.nix 47 48 ./hardware/digitalbitbox.nix 48 49 ./hardware/device-tree.nix 49 50 ./hardware/i2c.nix