diff options
author | Artturin <Artturin@artturin.com> | 2021-06-10 06:50:51 +0300 |
---|---|---|
committer | Artturin <Artturin@artturin.com> | 2021-06-11 03:00:29 +0300 |
commit | 9f396c9584ddb202b5b9c537c504ab4a6fa694a5 (patch) | |
tree | eabe75ee8d30f8216eb7bafaebdc6096ff685afd /nixos | |
parent | 5a29c4d3bfdaa9e77ba86d47f22cb116fc6c9d96 (diff) | |
download | nixlib-9f396c9584ddb202b5b9c537c504ab4a6fa694a5.tar nixlib-9f396c9584ddb202b5b9c537c504ab4a6fa694a5.tar.gz nixlib-9f396c9584ddb202b5b9c537c504ab4a6fa694a5.tar.bz2 nixlib-9f396c9584ddb202b5b9c537c504ab4a6fa694a5.tar.lz nixlib-9f396c9584ddb202b5b9c537c504ab4a6fa694a5.tar.xz nixlib-9f396c9584ddb202b5b9c537c504ab4a6fa694a5.tar.zst nixlib-9f396c9584ddb202b5b9c537c504ab4a6fa694a5.zip |
nixos/corectrl: init module
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/hardware/corectrl.nix | 62 | ||||
-rw-r--r-- | nixos/modules/module-list.nix | 1 |
2 files changed, 63 insertions, 0 deletions
diff --git a/nixos/modules/hardware/corectrl.nix b/nixos/modules/hardware/corectrl.nix new file mode 100644 index 000000000000..3185f6486c71 --- /dev/null +++ b/nixos/modules/hardware/corectrl.nix @@ -0,0 +1,62 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.programs.corectrl; +in +{ + options.programs.corectrl = { + enable = mkEnableOption '' + A tool to overclock amd graphics cards and processors. + Add your user to the corectrl group to run corectrl without needing to enter your password + ''; + + gpuOverclock = { + enable = mkEnableOption '' + true + ''; + ppfeaturemask = mkOption { + type = types.str; + 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 = mkIf cfg.enable (lib.mkMerge [ + { + environment.systemPackages = [ pkgs.corectrl ]; + + services.dbus.packages = [ pkgs.corectrl ]; + + 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 ]; +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 06f9a05cf666..b350bcfedae1 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -44,6 +44,7 @@ ./hardware/ckb-next.nix ./hardware/cpu/amd-microcode.nix ./hardware/cpu/intel-microcode.nix + ./hardware/corectrl.nix ./hardware/digitalbitbox.nix ./hardware/device-tree.nix ./hardware/i2c.nix |