1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-20 04:31:52 +00:00
nixpkgs/nixos/modules/hardware
Ambroz Bizjak f26153754a nixos/xserver: Implement configuration of NVIDIA Optimus via PRIME
This adds configuration options which automate the configuration of NVIDIA Optimus using PRIME. This allows using the NVIDIA proprietary driver on Optimus laptops, in order to render using the NVIDIA GPU while outputting to displays connected only to the integrated Intel GPU. It also adds an option for enabling kernel modesetting for the NVIDIA driver (via a kernel command line flag); this is particularly useful together with Optimus/PRIME because it fixes tearing on PRIME-connected screens.

The user still needs to enable the Optimus/PRIME feature and specify the bus IDs of the Intel and NVIDIA GPUs, but this is still much easier for users and more reliable. The implementation handles both the X configuration file as well as getting display managers to run certain necessary `xrandr` commands just after X has started.

Configuration of commands run after X startup is done using a new configuration option `services.xserver.displayManager.setupCommands`. Support for this option is implemented for LightDM, GDM and SDDM; all of these have been tested with this feature including logging into a Plasma session.

Note: support of `setupCommands` for GDM is implemented by making GDM run the session executable via a wrapper; the wrapper will run the `setupCommands` before execing. This seemed like the simplest and most reliable approach, and solves running these commands both for GDM's X server and user X servers (GDM starts separate X servers for itself and user sessions). An alternative approach would be with autostart files but that seems harder to set up and less reliable.

Note that some simple features for X configuration file generation (in `xserver.nix`) are added which are used in the implementation:
- `services.xserver.extraConfig`: Allows adding arbitrary new sections. This is used to add the Device section for the Intel GPU.
- `deviceSection` and `screenSection` within `services.xserver.drivers`. This allows the nvidia configuration module to add additional contents into the `Device` and `Screen` sections of the "nvidia" driver, and not into such sections for other drivers that may be enabled.
2018-07-09 18:46:13 +02:00
..
cpu microcode updates: prepend first in initrd 2017-02-27 17:12:33 +01:00
network nixos/modules: clean up wireless firmware options 2017-10-07 01:48:02 +02:00
raid hpsa service: fallout from #28557 merge and revert 2017-09-13 07:55:48 +02:00
sensor iio-sensor-proxy: init at 2.2 and nixos module 2017-02-25 08:46:46 +08:00
video nixos/xserver: Implement configuration of NVIDIA Optimus via PRIME 2018-07-09 18:46:13 +02:00
all-firmware.nix rtl8723bs: Only include in enableAllFirmware if valid 2018-02-22 08:52:50 -05:00
brightnessctl.nix brightnessctl: init at 0.3.2 (#42102) 2018-06-16 18:15:42 -04:00
ckb.nix ckb: init at 0.2.6 2017-01-12 18:25:14 +00:00
digitalbitbox.nix digitalbitbox: init at 2.2.2 (#33787) 2018-02-27 22:40:22 +00:00
ksm.nix
mcelog.nix mcelog: use .service file from upstream 2017-07-27 13:06:20 +08:00
nitrokey.nix nitrokey module: init 2017-05-26 00:47:46 +02:00
onlykey.nix config.hardware.onlykey configuration option 2018-03-18 12:49:13 +07:00
onlykey.udev config.hardware.onlykey configuration option 2018-03-18 12:49:13 +07:00
opengl.nix opengl service: don't override mesa non-drivers in runtime 2018-03-26 14:02:06 +03:00
pcmcia.nix
usb-wwan.nix usb-wwan: nixos module 2017-02-21 16:35:27 +08:00