at 24.11-pre 2.0 kB view raw
1{ config, pkgs, lib, ... }: 2 3with lib; 4 5let 6 cfg = config.programs.tuxclocker; 7in 8{ 9 options.programs.tuxclocker = { 10 enable = mkEnableOption '' 11 TuxClocker, a hardware control and monitoring program 12 ''; 13 14 enableAMD = mkEnableOption '' 15 AMD GPU controls. 16 Sets the `amdgpu.ppfeaturemask` kernel parameter to 0xfffd7fff to enable all TuxClocker controls 17 ''; 18 19 enabledNVIDIADevices = mkOption { 20 type = types.listOf types.int; 21 default = [ ]; 22 example = [ 0 1 ]; 23 description = '' 24 Enable NVIDIA GPU controls for a device by index. 25 Sets the `Coolbits` Xorg option to enable all TuxClocker controls. 26 ''; 27 }; 28 29 useUnfree = mkOption { 30 type = types.bool; 31 default = false; 32 example = true; 33 description = '' 34 Whether to use components requiring unfree dependencies. 35 Disabling this allows you to get everything from the binary cache. 36 ''; 37 }; 38 }; 39 40 config = let 41 package = if cfg.useUnfree then pkgs.tuxclocker else pkgs.tuxclocker-without-unfree; 42 in 43 mkIf cfg.enable { 44 environment.systemPackages = [ 45 package 46 ]; 47 48 services.dbus.packages = [ 49 package 50 ]; 51 52 # MSR is used for some features 53 boot.kernelModules = [ "msr" ]; 54 55 # https://download.nvidia.com/XFree86/Linux-x86_64/430.14/README/xconfigoptions.html#Coolbits 56 services.xserver.config = let 57 configSection = (i: '' 58 Section "Device" 59 Driver "nvidia" 60 Option "Coolbits" "31" 61 Identifier "Device-nvidia[${toString i}]" 62 EndSection 63 ''); 64 in 65 concatStrings (map configSection cfg.enabledNVIDIADevices); 66 67 # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_shared.h#n207 68 # Enable everything modifiable in TuxClocker 69 boot.kernelParams = mkIf cfg.enableAMD [ "amdgpu.ppfeaturemask=0xfffd7fff" ]; 70 }; 71}