nixos/modules/hardware/nvidia/default.nix

74 lines
1.7 KiB
Nix
Raw Normal View History

2023-07-08 20:23:36 +04:00
{
outputs,
options,
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.modules.hardware.nvidia;
2023-08-13 20:27:13 +04:00
busIDType = lib.types.strMatching "([[:print:]]+[\:\@][0-9]{1,3}\:[0-9]{1,2}\:[0-9])?";
in {
2023-08-13 20:32:50 +04:00
imports = [
./prime.nix
];
2023-07-08 20:23:36 +04:00
options.modules.hardware.nvidia = {
enable = mkEnableOption false;
prime.enable = mkEnableOption false;
2023-08-13 20:29:59 +04:00
prime.intelBusId = mkOption {
2023-08-13 20:27:13 +04:00
type = busIDType;
default = "";
};
prime.nvidiaBusId = mkOption {
2023-08-13 20:27:13 +04:00
type = busIDType;
default = "";
};
2023-07-08 20:23:36 +04:00
};
config = mkIf cfg.enable {
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
2023-07-08 20:23:36 +04:00
# regardless of if you have intel/nvidia
2023-07-17 18:42:23 +04:00
# or amd/nvidia this HAS to be nvidia only
# or else it will not work
services.xserver.videoDrivers = ["nvidia"];
2023-07-08 20:23:36 +04:00
hardware.nvidia = {
# wayland support
modesetting.enable = true;
# TODO(sako) add this as a cfg option
# set to true if you have an rtx or newer graphics card
# else set to false
open = false;
# settings
nvidiaSettings = true;
# screen tearing fix
# might consume more power?? dont know, shouldnt be an issue hopefully
forceFullCompositionPipeline = true;
2023-07-08 20:23:36 +04:00
# Package
package = config.boot.kernelPackages.nvidiaPackages.stable;
# TODO(sako) ALSO add these as a cfg option
prime = {
offload = {
enable = cfg.prime;
enableOffloadCmd = cfg.prime;
2023-07-08 20:23:36 +04:00
};
#intelBusId = "PCI:0:2:0";
#nvidiaBusId = "PCI:1:0:0";
intelBusId = cfg.intelBusId;
nvidiaBusId = cfg.nvidiaBusId;
2023-07-08 20:23:36 +04:00
};
};
};
}