This commit is contained in:
+30
-21
@@ -17,8 +17,7 @@
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
defaultText = lib.literalExpression
|
||||
"config.boot.kernelPackages.nvidiaPackages.stable";
|
||||
defaultText = lib.literalExpression "config.boot.kernelPackages.nvidiaPackages.stable";
|
||||
description = "The NVIDIA driver package to use.";
|
||||
};
|
||||
|
||||
@@ -26,7 +25,11 @@
|
||||
enable = lib.mkEnableOption "NVIDIA Optimus PRIME (hybrid graphics)";
|
||||
|
||||
mode = lib.mkOption {
|
||||
type = lib.types.enum [ "offload" "sync" "reverse-sync" ];
|
||||
type = lib.types.enum [
|
||||
"offload"
|
||||
"sync"
|
||||
"reverse-sync"
|
||||
];
|
||||
default = "offload";
|
||||
description = ''
|
||||
Which PRIME mode to use.
|
||||
@@ -63,13 +66,13 @@
|
||||
hardware.graphics.enable = true;
|
||||
|
||||
services.xserver.videoDrivers =
|
||||
if config.modules.nvidia.prime.enable
|
||||
&& config.modules.nvidia.prime.mode == "offload"
|
||||
then [
|
||||
(if config.modules.nvidia.prime.amdBusId != "" then "amdgpu" else "modesetting")
|
||||
"nvidia"
|
||||
]
|
||||
else [ "nvidia" ];
|
||||
if config.modules.nvidia.prime.enable && config.modules.nvidia.prime.mode == "offload" then
|
||||
[
|
||||
(if config.modules.nvidia.prime.amdBusId != "" then "amdgpu" else "modesetting")
|
||||
"nvidia"
|
||||
]
|
||||
else
|
||||
[ "nvidia" ];
|
||||
|
||||
hardware.nvidia = {
|
||||
modesetting.enable = true;
|
||||
@@ -83,21 +86,27 @@
|
||||
prime = lib.mkIf config.modules.nvidia.prime.enable (
|
||||
let
|
||||
busIds = lib.filterAttrs (_: v: v != "") {
|
||||
intelBusId = config.modules.nvidia.prime.intelBusId;
|
||||
intelBusId = config.modules.nvidia.prime.intelBusId;
|
||||
amdgpuBusId = config.modules.nvidia.prime.amdBusId;
|
||||
nvidiaBusId = config.modules.nvidia.prime.nvidiaBusId;
|
||||
};
|
||||
modeConfig =
|
||||
if config.modules.nvidia.prime.mode == "offload" then {
|
||||
offload.enable = true;
|
||||
offload.enableOffloadCmd = true;
|
||||
} else if config.modules.nvidia.prime.mode == "sync" then {
|
||||
sync.enable = true;
|
||||
} else {
|
||||
reverseSync.enable = true;
|
||||
allowExternalGpu = false;
|
||||
};
|
||||
in busIds // modeConfig
|
||||
if config.modules.nvidia.prime.mode == "offload" then
|
||||
{
|
||||
offload.enable = true;
|
||||
offload.enableOffloadCmd = true;
|
||||
}
|
||||
else if config.modules.nvidia.prime.mode == "sync" then
|
||||
{
|
||||
sync.enable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
reverseSync.enable = true;
|
||||
allowExternalGpu = false;
|
||||
};
|
||||
in
|
||||
busIds // modeConfig
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user