nixos/nvidia: prime.sync.{intel,nvidia}BusId -> prime.{intel,nvidia}BusId

This commit is contained in:
Edmund Wu 2019-08-14 08:18:28 -04:00
parent aca9ffe893
commit e8daa1e35c
No known key found for this signature in database
GPG Key ID: 76AA3F9F2BD3E3A0

View File

@ -34,7 +34,8 @@ let
enabled = nvidia_x11 != null; enabled = nvidia_x11 != null;
cfg = config.hardware.nvidia; cfg = config.hardware.nvidia;
syncCfg = cfg.prime.sync; pCfg = cfg.prime;
syncCfg = pCfg.sync;
in in
{ {
@ -42,8 +43,8 @@ in
[ [
(mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "enable" ] [ "hardware" "nvidia" "prime" "sync" "enable" ]) (mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "enable" ] [ "hardware" "nvidia" "prime" "sync" "enable" ])
(mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "allowExternalGpu" ] [ "hardware" "nvidia" "prime" "sync" "allowExternalGpu" ]) (mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "allowExternalGpu" ] [ "hardware" "nvidia" "prime" "sync" "allowExternalGpu" ])
(mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "nvidiaBusId" ] [ "hardware" "nvidia" "prime" "sync" "nvidiaBusId" ]) (mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "nvidiaBusId" ] [ "hardware" "nvidia" "prime" "nvidiaBusId" ])
(mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "intelBusId" ] [ "hardware" "nvidia" "prime" "sync" "intelBusId" ]) (mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "intelBusId" ] [ "hardware" "nvidia" "prime" "intelBusId" ])
]; ];
options = { options = {
@ -60,6 +61,26 @@ in
''; '';
}; };
hardware.nvidia.prime.nvidiaBusId = mkOption {
type = types.str;
default = "";
example = "PCI:1:0:0";
description = ''
Bus ID of the NVIDIA GPU. You can find it using lspci; for example if lspci
shows the NVIDIA GPU at "01:00.0", set this option to "PCI:1:0:0".
'';
};
hardware.nvidia.prime.intelBusId = mkOption {
type = types.str;
default = "";
example = "PCI:0:2:0";
description = ''
Bus ID of the Intel GPU. You can find it using lspci; for example if lspci
shows the Intel GPU at "00:02.0", set this option to "PCI:0:2:0".
'';
};
hardware.nvidia.prime.sync.enable = mkOption { hardware.nvidia.prime.sync.enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
@ -74,8 +95,8 @@ in
be the only driver there. be the only driver there.
If this is enabled, then the bus IDs of the NVIDIA and Intel GPUs have to be If this is enabled, then the bus IDs of the NVIDIA and Intel GPUs have to be
specified (<option>hardware.nvidia.prime.sync.nvidiaBusId</option> and specified (<option>hardware.nvidia.prime.nvidiaBusId</option> and
<option>hardware.nvidia.prime.sync.intelBusId</option>). <option>hardware.nvidia.prime.intelBusId</option>).
If you enable this, you may want to also enable kernel modesetting for the If you enable this, you may want to also enable kernel modesetting for the
NVIDIA driver (<option>hardware.nvidia.modesetting.enable</option>) in order NVIDIA driver (<option>hardware.nvidia.modesetting.enable</option>) in order
@ -94,26 +115,6 @@ in
Configure X to allow external NVIDIA GPUs when using optimus. Configure X to allow external NVIDIA GPUs when using optimus.
''; '';
}; };
hardware.nvidia.prime.sync.nvidiaBusId = mkOption {
type = types.str;
default = "";
example = "PCI:1:0:0";
description = ''
Bus ID of the NVIDIA GPU. You can find it using lspci; for example if lspci
shows the NVIDIA GPU at "01:00.0", set this option to "PCI:1:0:0".
'';
};
hardware.nvidia.prime.sync.intelBusId = mkOption {
type = types.str;
default = "";
example = "PCI:0:2:0";
description = ''
Bus ID of the Intel GPU. You can find it using lspci; for example if lspci
shows the Intel GPU at "00:02.0", set this option to "PCI:0:2:0".
'';
};
}; };
config = mkIf enabled { config = mkIf enabled {
@ -125,7 +126,7 @@ in
{ {
assertion = !syncCfg.enable || assertion = !syncCfg.enable ||
(syncCfg.nvidiaBusId != "" && syncCfg.intelBusId != ""); (pCfg.nvidiaBusId != "" && pCfg.intelBusId != "");
message = '' message = ''
When NVIDIA Optimus via PRIME is enabled, the GPU bus IDs must configured. When NVIDIA Optimus via PRIME is enabled, the GPU bus IDs must configured.
''; '';
@ -149,7 +150,7 @@ in
modules = [ nvidia_x11.bin ]; modules = [ nvidia_x11.bin ];
deviceSection = optionalString syncCfg.enable deviceSection = optionalString syncCfg.enable
'' ''
BusID "${syncCfg.nvidiaBusId}" BusID "${pCfg.nvidiaBusId}"
${optionalString syncCfg.allowExternalGpu "Option \"AllowExternalGpus\""} ${optionalString syncCfg.allowExternalGpu "Option \"AllowExternalGpus\""}
''; '';
screenSection = screenSection =
@ -164,7 +165,7 @@ in
Section "Device" Section "Device"
Identifier "nvidia-optimus-intel" Identifier "nvidia-optimus-intel"
Driver "modesetting" Driver "modesetting"
BusID "${syncCfg.intelBusId}" BusID "${pCfg.intelBusId}"
Option "AccelMethod" "none" Option "AccelMethod" "none"
EndSection EndSection
''; '';