feat: nvidia drivers for oreo
This commit is contained in:
Generated
+3
-3
@@ -110,11 +110,11 @@
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1780719019,
|
||||
"narHash": "sha256-DZCJn3xaUSztvxw8xtbRSBxRQRzAoWvzGFAc0NLZdjw=",
|
||||
"lastModified": 1780913839,
|
||||
"narHash": "sha256-SAApjWmx0ckoH/LddeOIDHqlLOwuCbz4ViObvf/N2RE=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nix4vscode",
|
||||
"rev": "efe7a04bb221089e7ecb0b663441afc2a40eb02d",
|
||||
"rev": "b6f45dca18b3f4ab2f8029bce512cde59f950a89",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
../../modules/core.nix
|
||||
../../modules/plasma.nix
|
||||
../../modules/security.nix
|
||||
../../modules/nvidia.nix
|
||||
];
|
||||
|
||||
networking.hostName = "oreo";
|
||||
@@ -33,5 +34,17 @@
|
||||
polkitPolicyOwners = [ "alex" ];
|
||||
};
|
||||
|
||||
modules.nvidia = {
|
||||
enable = false;
|
||||
open = true;
|
||||
# Only needed if this is a laptop with hybrid graphics:
|
||||
prime = {
|
||||
enable = true;
|
||||
mode = "offload";
|
||||
intelBusId = "PCI:0:2.0";
|
||||
nvidiaBusId = "PCI:1:0:0";
|
||||
};
|
||||
};
|
||||
|
||||
system.stateVersion = "25.11";
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
gptfdisk
|
||||
exfatprogs
|
||||
parted
|
||||
lshw
|
||||
];
|
||||
|
||||
nixpkgs.overlays = [ inputs.nix4vscode.overlays.default ];
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
{
|
||||
options.modules.nvidia = {
|
||||
enable = lib.mkEnableOption "NVIDIA proprietary drivers";
|
||||
|
||||
open = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Use the open-source NVIDIA kernel module.
|
||||
Set to true for Turing (RTX 20-series) and newer.
|
||||
Set to false for older architectures.
|
||||
'';
|
||||
};
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
defaultText = lib.literalExpression
|
||||
"config.boot.kernelPackages.nvidiaPackages.stable";
|
||||
description = "The NVIDIA driver package to use.";
|
||||
};
|
||||
|
||||
prime = {
|
||||
enable = lib.mkEnableOption "NVIDIA Optimus PRIME (hybrid graphics)";
|
||||
|
||||
mode = lib.mkOption {
|
||||
type = lib.types.enum [ "offload" "sync" "reverse-sync" ];
|
||||
default = "offload";
|
||||
description = ''
|
||||
Which PRIME mode to use.
|
||||
offload — iGPU handles everything; dGPU used on demand (best battery)
|
||||
sync — dGPU always active; best performance, less tearing
|
||||
reverse-sync — experimental; dGPU primary, iGPU for outputs
|
||||
'';
|
||||
};
|
||||
|
||||
intelBusId = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
example = "PCI:0:2:0";
|
||||
description = "PCI bus ID of the Intel iGPU (from lshw -c display).";
|
||||
};
|
||||
|
||||
amdBusId = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
example = "PCI:54:0:0";
|
||||
description = "PCI bus ID of the AMD iGPU (from lshw -c display). Leave empty if Intel.";
|
||||
};
|
||||
|
||||
nvidiaBusId = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
example = "PCI:14:0:0";
|
||||
description = "PCI bus ID of the NVIDIA dGPU (from lshw -c display).";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.modules.nvidia.enable {
|
||||
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" ];
|
||||
|
||||
hardware.nvidia = {
|
||||
modesetting.enable = true;
|
||||
open = config.modules.nvidia.open;
|
||||
nvidiaSettings = true;
|
||||
package = config.modules.nvidia.package;
|
||||
|
||||
powerManagement.enable = false;
|
||||
powerManagement.finegrained = false;
|
||||
|
||||
prime = lib.mkIf config.modules.nvidia.prime.enable (
|
||||
let
|
||||
busIds = lib.filterAttrs (_: v: v != "") {
|
||||
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
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user