feat: manage nvidia graphics as a module

This commit is contained in:
Youwen Wu 2024-12-24 18:19:54 -08:00
parent 190faacb64
commit 104a61a055
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3

View file

@ -0,0 +1,51 @@
{
lib,
config,
pkgs,
...
}:
let
cfg = config.liminalOS.system.graphics;
in
{
options.liminalOS.system.graphics = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to set up basic graphics settings and options.
'';
};
nvidia = {
enable = lib.mkEnableOption "recommended nvidia drivers and configuration";
optimus-prime.enable = lib.mkEnableOption "Nvidia OPTIMUS and PRIME";
optimus-prime.powerMode = lib.mkOption {
type = lib.types.enum [
"powersaving"
"performance"
];
default = "performance";
description = ''
Whether to use Nvidia OPTIMUS with maximum performance using the discrete graphics card, or to use offload mode to primarily use the integrated GPU and save power.
'';
};
suppressUnfreeWarning = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to disable the assertion that warns the user if they try to enable proprietary nvidia drivers without setting allowUnfree.
'';
};
};
};
config = lib.mkIf cfg.enable {
hardware.nvidia = lib.mkIf cfg.nvidia.enable {
modesetting.enable = true;
powerManagement.enable = true;
powerManagement.finegrained = false;
open = true;
package = config.boot.kernelPackages.nvidiaPackages.beta;
};
};
}