fix(gui): improve driver selection correctness

This commit is contained in:
514fpv 2024-01-05 22:23:41 +08:00
parent bb2eede8e6
commit b606aa73b8
Signed by: koishi
SSH key fingerprint: SHA256:axz0uIzzY+5W19i7QOUuiw5LSqhKfCBKPf3L4xFRxLw
3 changed files with 18 additions and 34 deletions

View file

@ -3,10 +3,13 @@
, config
, ... }: with lib; let
cfg = config.faucet.gui;
intel = cfg.type == "intel" || (cfg.type == "prime" && config.hardware.nvidia.prime.intelBusId != "");
amdgpu = cfg.type == "amdgpu" || (cfg.type == "prime" && config.hardware.nvidia.prime.amdgpuBusId != "");
nvidia = cfg.type == "nvidia" || cfg.type == "prime";
in {
imports = [
./plymouth.nix
./va.nix
./greetd.nix
];
@ -17,13 +20,6 @@ in {
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 {
@ -31,15 +27,23 @@ in {
enable = true;
driSupport = true;
driSupport32Bit = true;
# https://nixos.wiki/wiki/Accelerated_Video_Playback
extraPackages = with pkgs; optionals intel [
intel-media-driver # LIBVA_DRIVER_NAME=iHD
vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
vaapiVdpau
libvdpau-va-gl
] ++ optional nvidia nvidia-vaapi-driver;
};
services.xserver.videoDrivers =
optional ((cfg.type == "nvidia") || (cfg.type == "prime")) "nvidia" ++
optional nvidia "nvidia" ++
optional (cfg.type == "amdgpu") "amdgpu";
# inhibits default display manager
services.xserver.displayManager.startx.enable = mkDefault true;
hardware.nvidia = mkIf ((cfg.type == "nvidia") || (cfg.type == "prime")) {
hardware.nvidia = mkIf nvidia {
modesetting.enable = true;
nvidiaSettings = true;
@ -56,7 +60,9 @@ in {
};
boot.initrd.kernelModules =
optional (cfg.type == "amdgpu") "amdgpu" ++
optional (cfg.type == "prime") cfg.prime.integrated;
optional amdgpu "amdgpu" ++
optional intel "i915";
boot.kernelParams = optional intel "i915.fastboot=1";
};
}

View file

@ -13,7 +13,6 @@ in mkIf cfg.enable {
kernelParams = [
"quiet"
"splash"
"i915.fastboot=1"
"loglevel=3"
"rd.systemd.show_status=false"
"rd.udev.log_level=3"

View file

@ -1,21 +0,0 @@
# https://nixos.wiki/wiki/Accelerated_Video_Playback
{ pkgs
, lib
, config
, ... }: with lib; let
cfg = config.faucet.gui;
in mkIf cfg.enable {
nixpkgs.config.packageOverrides = pkgs: {
vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
};
hardware.opengl = {
extraPackages = with pkgs; optionals ((cfg.type == "intel") || (cfg.type == "prime")) [
intel-media-driver # LIBVA_DRIVER_NAME=iHD
vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
vaapiVdpau
libvdpau-va-gl
] ++ optional ((cfg.type == "nvidia") || (cfg.type == "prime")) nvidia-vaapi-driver;
};
}