Hello,
I just got a System76 Serval laptop, and I’m struggling to get Xorg working with the nvidia drivers. My card is an RTX 4060:
[little-dude@nixos:~]$ nix-shell -p pciutils --run "lspci -nn | grep VGA"
00:02.0 VGA compatible controller [0300]: Intel Corporation Raptor Lake-S UHD Graphics [8086:a788] (rev 04)
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation AD107M [GeForce RTX 4060 Max-Q / Mobile] [10de:28e0] (rev a1)
And I tried many variants of the following config:
{ config, pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ];
nixpkgs.config.allowUnfree = true;
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
hardware = {
opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
nvidia = {
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
powerManagement.enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Do not disable this unless your GPU is unsupported or if you have a good reason to.
open = true;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# We have a GeForce RTX 4060 which is not in the legacy GPU list (https://www.nvidia.com/en-us/drivers/unix/legacy-gpu/)
# Therefore, the stable drivers should work.
package = config.boot.kernelPackages.nvidiaPackages.stable;
prime = {
offload = {
enable = true;
enableOffloadCmd = true;
};
intelBusId = "PCI:1:0:0";
nvidiaBusId = "PCI:0:2:0";
};
};
};
# See: https://nixos.wiki/wiki/Intel_Graphics
#
# [little-dude@nixos:~]$ nix-shell -p pciutils --run "lspci -nn | grep VGA"
# 00:02.0 VGA compatible controller [0300]: Intel Corporation Raptor Lake-S UHD Graphics [8086:a788] (rev 04)
# 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation AD107M [GeForce RTX 4060 Max-Q / Mobile] [10de:28e0] (rev a1)
# boot.kernelParams = [ "i915.force_probe=a788" ];
services.xserver = {
enable = true;
# Load nvidia driver for Xorg and Wayland (Xorg in our case)
# videoDrivers = ["nvidia"];
displayManager = {
gdm = {
enable = true;
# Screen sharing doesn't work for Teams in Wayland
wayland = false;
};
};
layout = "us";
xkbOptions = "eurosign:e,caps:escape";
desktopManager.gnome.enable = true;
};
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.little-dude = {
isNormalUser = true;
uid = 1000;
group = "users";
extraGroups = [ "wheel" ];
};
environment.systemPackages = with pkgs; [ lshw neovim firefox nixfmt git xsel ];
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
system.copySystemConfiguration = true;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05";
}
Xorg fails to start:
ct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: (EE) modeset(0): Failed to create pixmap
Oct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: (EE)
Oct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: Fatal server error:
Oct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: (EE) failed to create screen resources(EE)
Oct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: (EE)
Oct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: Please consult the The X.Org Foundation support
Oct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: at http://wiki.x.org
Oct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: for help.
Oct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: (EE) Please also check the log file at "/dev/null" for additional information.
Oct 27 18:03:55 nixos /nix/store/vzwrzdz8bxiiwdh70j6lapghjskmm2ba-gdm-44.1/libexec/gdm-x-session[1779]: (EE)
Oct 27 18:03:56 nixos kernel: NVRM unixCallVideoBIOS: int10h(4f02, 0000) vesa call failed! (4f02, 0000)
Oct 27 18:03:56 nixos kernel: NVRM nvCheckOkFailedNoLog: Check failed: Failure: Generic Error [NV_ERR_GENERIC] (0x0000FFFF) returned from pRmApi->Control(pRmApi, nv->rmapi.hClient, nv->rmapi.hSubDevice, NV2080_CTRL_CMD_INTERNAL_DISPLAY_POST_RESTORE, &restoreParams, sizeof(restoreParams)) @ unix_console.c:197
The full boot logs can be found here
I tried several variants of this:
- stable drivers,
open = false;
prime enabled: gist - beta drivers,
open = true;
prime enabled: gist - beta drivers,
open = false;
, prime enabled: gist - beta drivers,
open = true
;` prime disabled: gist
When prime is disabled, the logs show that Xorg starts. However, the screen remains black… Moreover, since this is a laptop I do want prime enabled anyway. Wrt to my prime config, here is where I got the bus numbers from:
[little-dude@nixos:~]$ sudo lshw -c display
[sudo] password for little-dude:
*-display
description: i915drmfb
physical id: 0
bus info: pci@0000:01:00.0 ---------> 1:0:0
logical name: /dev/fb0
version: a1
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list fb
configuration: depth=32 latency=0 mode=1920x1080 visual=truecolor xres=1920 yres=1080
resources: iomemory:120-11f iomemory:140-13f memory:81000000-81ffffff memory:1200000000-13ffffffff memory:1400000000-1401ffffff ioport:6000(size=128) memory:82000000-8207ffff
*-display
physical id: 2
bus info: pci@0000:00:02.0 --------------> 0:2:0
version: 04
width: 64 bits
clock: 33MHz
capabilities: pciexpress msi pm bus_master cap_list rom
configuration: driver=i915 latency=0
resources: irq:201 memory:83000000-83ffffff memory:90000000-9fffffff ioport:1000(size=64) memory:c0000-dffff memory:1180000000-1186ffffff memory:10a0000000-117fffffff