feat(gui): add graphics driver options

This commit is contained in:
514fpv 2024-01-02 16:20:52 +08:00
parent a0f20b9f1a
commit 635d7fd0f3
Signed by: koishi
SSH key fingerprint: SHA256:axz0uIzzY+5W19i7QOUuiw5LSqhKfCBKPf3L4xFRxLw

55
faucet/gui/default.nix Normal file
View file

@ -0,0 +1,55 @@
{ pkgs
, lib
, config
, ... }: with lib; let
cfg = config.faucet.gui;
in {
options.faucet.gui = {
enable = mkEnableOption "various setup required for GUI and support software";
type = mkOption {
type = with types; enum [ "intel" "amdgpu" "nvidia" "prime" ];
description = "type of graphics acceleration used";
};
prime = {
integrated = mkOption {
type = with types; str;
default = "i915";
description = "integrated gpu driver";
};
};
};
config = mkIf cfg.enable {
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
services.xserver.videoDrivers =
optional ((cfg.type == "nvidia") || (cfg.type == "prime")) "nvidia" ++
optional (cfg.type == "amdgpu") "amdgpu";
# has to be enabled even when using wayland
services.xserver.enable = true;
hardware.nvidia = mkIf ((cfg.type == "nvidia") || (cfg.type == "prime")) {
modesetting.enable = true;
nvidiaSettings = true;
prime = mkIf (cfg.type == "prime") {
offload = {
enable = true;
enableOffloadCmd = true;
};
};
powerManagement.enable = false;
powerManagement.finegrained = false;
open = false;
};
boot.initrd.kernelModules =
optional (cfg.type == "amdgpu") "amdgpu" ++
optional (cfg.type == "prime") cfg.prime.integrated;
};
}