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