diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index f792194da224..0a3c3fafeca1 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -27,6 +27,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} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 11c344f99903..52c6fe5028f1 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -770,6 +770,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 diff --git a/nixos/modules/services/misc/tuxclocker.nix b/nixos/modules/services/misc/tuxclocker.nix new file mode 100644 index 000000000000..5969f75b8e30 --- /dev/null +++ b/nixos/modules/services/misc/tuxclocker.nix @@ -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" ]; + }; +} diff --git a/pkgs/applications/misc/tuxclocker/default.nix b/pkgs/applications/misc/tuxclocker/default.nix new file mode 100644 index 000000000000..5592c8e2cdec --- /dev/null +++ b/pkgs/applications/misc/tuxclocker/default.nix @@ -0,0 +1,66 @@ +{ lib +, stdenv +, boost +, fetchFromGitHub +, git +, makeWrapper +, meson +, ninja +, pkg-config +, python3 +, qtbase +, qtcharts +, tuxclocker-plugins +, wrapQtAppsHook +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "tuxclocker"; + version = "1.4.0"; + + src = fetchFromGitHub { + owner = "Lurkki14"; + repo = "tuxclocker"; + fetchSubmodules = true; + rev = "${finalAttrs.version}"; + hash = "sha256-8dtuZXBWftXNQpqYgNQOayPGfvEIu9QfbqDShfkt1qA="; + }; + + # Meson doesn't find boost without these + BOOST_INCLUDEDIR = "${lib.getDev boost}/include"; + BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; + + nativeBuildInputs = [ + git + makeWrapper + meson + ninja + pkg-config + wrapQtAppsHook + ]; + + buildInputs = [ + boost + qtbase + qtcharts + ]; + + postInstall = '' + wrapProgram "$out/bin/tuxclockerd" \ + --prefix "TEXTDOMAINDIR" : "${tuxclocker-plugins}/share/locale" \ + --prefix "TUXCLOCKER_PLUGIN_PATH" : "${tuxclocker-plugins}/lib/tuxclocker/plugins" \ + --prefix "PYTHONPATH" : "${python3.pkgs.hwdata}/${python3.sitePackages}" + ''; + + mesonFlags = [ + "-Dplugins=false" + ]; + + meta = with lib; { + description = "Qt overclocking tool for GNU/Linux"; + homepage = "https://github.com/Lurkki14/tuxclocker"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ lurkki ]; + platforms = platforms.linux; + }; +}) diff --git a/pkgs/by-name/tu/tuxclocker-nvidia-plugin/no-cpu-plugin.patch b/pkgs/by-name/tu/tuxclocker-nvidia-plugin/no-cpu-plugin.patch new file mode 100644 index 000000000000..d6d864fb9789 --- /dev/null +++ b/pkgs/by-name/tu/tuxclocker-nvidia-plugin/no-cpu-plugin.patch @@ -0,0 +1,14 @@ +diff --git a/src/plugins/meson.build b/src/plugins/meson.build +index cdd3b5b..a5a2174 100644 +--- a/src/plugins/meson.build ++++ b/src/plugins/meson.build +@@ -63,9 +63,3 @@ if all_nvidia_linux_libs + install : true, + link_with : libtuxclocker) + endif +- +-shared_library('cpu', 'CPU.cpp', 'Utils.cpp', +- include_directories : [incdir, fplus_inc], +- install_dir : get_option('libdir') / 'tuxclocker' / 'plugins', +- install : true, +- link_with : libtuxclocker) diff --git a/pkgs/by-name/tu/tuxclocker-nvidia-plugin/package.nix b/pkgs/by-name/tu/tuxclocker-nvidia-plugin/package.nix new file mode 100644 index 000000000000..dac3b342c4c2 --- /dev/null +++ b/pkgs/by-name/tu/tuxclocker-nvidia-plugin/package.nix @@ -0,0 +1,34 @@ +{ lib +, stdenv +, boost +, libX11 +, libXext +, linuxPackages +, openssl +, tuxclocker-plugins +}: + +stdenv.mkDerivation { + pname = "tuxclocker-nvidia-plugin"; + + inherit (tuxclocker-plugins) src version meta BOOST_INCLUDEDIR BOOST_LIBRARYDIR nativeBuildInputs; + + buildInputs = [ + boost + libX11 + libXext + linuxPackages.nvidia_x11 + linuxPackages.nvidia_x11.settings.libXNVCtrl + openssl + ]; + + # Build doesn't have a way to disable building the CPU plugin, which is already + # provided by 'tuxclocker-plugins' + patches = [ ./no-cpu-plugin.patch ]; + + mesonFlags = [ + "-Ddaemon=false" + "-Dgui=false" + "-Drequire-nvidia=true" + ]; +} diff --git a/pkgs/by-name/tu/tuxclocker-plugins-with-unfree/package.nix b/pkgs/by-name/tu/tuxclocker-plugins-with-unfree/package.nix new file mode 100644 index 000000000000..f055cf111fa3 --- /dev/null +++ b/pkgs/by-name/tu/tuxclocker-plugins-with-unfree/package.nix @@ -0,0 +1,16 @@ +{ symlinkJoin +, tuxclocker-nvidia-plugin +, tuxclocker-plugins +}: + +symlinkJoin rec { + inherit (tuxclocker-plugins) version meta; + + pname = "tuxclocker-plugins-with-unfree"; + name = "${pname}-${version}"; + + paths = [ + tuxclocker-nvidia-plugin + tuxclocker-plugins + ]; +} diff --git a/pkgs/by-name/tu/tuxclocker-plugins/package.nix b/pkgs/by-name/tu/tuxclocker-plugins/package.nix new file mode 100644 index 000000000000..19c8fa52441b --- /dev/null +++ b/pkgs/by-name/tu/tuxclocker-plugins/package.nix @@ -0,0 +1,42 @@ +{ lib +, stdenv +, boost +, cmake +, gettext +, git +, libdrm +, meson +, ninja +, openssl +, pkg-config +, python3 +, tuxclocker +}: + +stdenv.mkDerivation { + inherit (tuxclocker) src version meta BOOST_INCLUDEDIR BOOST_LIBRARYDIR; + + pname = "tuxclocker-plugins"; + + nativeBuildInputs = [ + gettext + git + meson + ninja + pkg-config + (python3.withPackages(p: [ p.hwdata ])) + ]; + + buildInputs = [ + boost + libdrm + openssl + ]; + + mesonFlags = [ + "-Ddaemon=false" + "-Dgui=false" + "-Drequire-amd=true" + "-Drequire-python-hwdata=true" + ]; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e4736778d84b..82e1188b8c7c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -36014,6 +36014,12 @@ with pkgs; tut = callPackage ../applications/misc/tut { }; + tuxclocker = libsForQt5.callPackage ../applications/misc/tuxclocker { + tuxclocker-plugins = tuxclocker-plugins-with-unfree; + }; + + tuxclocker-without-unfree = libsForQt5.callPackage ../applications/misc/tuxclocker { }; + tuxedo-rs = callPackage ../os-specific/linux/tuxedo-rs { }; tuxguitar = callPackage ../applications/editors/music/tuxguitar {