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