nixos/coolercontrol: Add support for Nvidia hardware

This commit is contained in:
OPNA2608 2024-04-13 11:35:04 +02:00 committed by Guy Boldon
parent bbc0a5ee52
commit 29ef3d58b5
No known key found for this signature in database
GPG key ID: CF7BBB5BC7561BD3

View file

@ -10,28 +10,50 @@ in
{
##### interface
options = {
programs.coolercontrol.enable = lib.mkEnableOption (lib.mdDoc "CoolerControl GUI & its background services");
};
programs.coolercontrol = {
enable = lib.mkEnableOption (lib.mdDoc "CoolerControl GUI & its background services");
##### implementation
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs.coolercontrol; [
coolercontrol-gui
];
systemd = {
packages = with pkgs.coolercontrol; [
coolercontrol-liqctld
coolercontrold
];
# https://github.com/NixOS/nixpkgs/issues/81138
services = {
coolercontrol-liqctld.wantedBy = [ "multi-user.target" ];
coolercontrold.wantedBy = [ "multi-user.target" ];
nvidiaSupport = lib.mkOption {
type = lib.types.bool;
default = lib.elem "nvidia" config.services.xserver.videoDrivers;
defaultText = lib.literalExpression "lib.elem \"nvidia\" config.services.xserver.videoDrivers";
description = lib.mdDoc ''
Enable support for Nvidia GPUs.
'';
};
};
};
##### implementation
config = lib.mkIf cfg.enable (lib.mkMerge [
# Common
({
environment.systemPackages = with pkgs.coolercontrol; [
coolercontrol-gui
];
systemd = {
packages = with pkgs.coolercontrol; [
coolercontrol-liqctld
coolercontrold
];
# https://github.com/NixOS/nixpkgs/issues/81138
services = {
coolercontrol-liqctld.wantedBy = [ "multi-user.target" ];
coolercontrold.wantedBy = [ "multi-user.target" ];
};
};
})
# Nvidia support
(lib.mkIf cfg.nvidiaSupport {
systemd.services.coolercontrold.path = with config.boot.kernelPackages; [
nvidia_x11 # nvidia-smi
nvidia_x11.settings # nvidia-settings
];
})
]);
meta.maintainers = with lib.maintainers; [ OPNA2608 codifryed ];
}