Skip to content

Commit

Permalink
nixos/tuxclocker: init module
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurkki14 committed Dec 17, 2023
1 parent 46e9f82 commit 60cb6ee
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m

- [Clevis](https://github.com/latchset/clevis), a pluggable framework for automated decryption, used to unlock encrypted devices in initrd. Available as [boot.initrd.clevis.enable](#opt-boot.initrd.clevis.enable).

- [TuxClocker](https://github.com/Lurkki14/tuxclocker), a hardware control and monitoring program. Available as [programs.tuxclocker](#opt-programs.tuxclocker.enable).

## Backward Incompatibilities {#sec-release-24.05-incompatibilities}

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
./services/misc/tautulli.nix
./services/misc/tiddlywiki.nix
./services/misc/tp-auto-kbbl.nix
./services/misc/tuxclocker.nix
./services/misc/tzupdate.nix
./services/misc/uhub.nix
./services/misc/weechat.nix
Expand Down
71 changes: 71 additions & 0 deletions nixos/modules/services/misc/tuxclocker.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{ config, pkgs, lib, ... }:

with lib;

let
cfg = config.programs.tuxclocker;
in
{
options.programs.tuxclocker = {
enable = mkEnableOption (lib.mdDoc ''
TuxClocker, a hardware control and monitoring program
'');

enableAMD = mkEnableOption (lib.mdDoc ''
AMD GPU controls.
Sets the `amdgpu.ppfeaturemask` kernel parameter to 0xfffd7fff to enable all TuxClocker controls
'');

enabledNVIDIADevices = mkOption {
type = types.listOf types.int;
default = [ ];
example = [ 0 1 ];
description = lib.mdDoc ''
Enable NVIDIA GPU controls for a device by index.
Sets the `Coolbits` Xorg option to enable all TuxClocker controls.
'';
};

useUnfree = mkOption {
type = types.bool;
default = false;
example = true;
description = lib.mdDoc ''
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
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
concatStrings (map configSection cfg.enabledNVIDIADevices);

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_shared.h#n207
# Enable everything modifiable in TuxClocker
boot.kernelParams = mkIf cfg.enableAMD [ "amdgpu.ppfeaturemask=0xfffd7fff" ];
};
}

0 comments on commit 60cb6ee

Please sign in to comment.