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