How to correct nvidia driver resolution

I usually run nixos 20.03 & am testing 21.05 on a different partition. The display appears crisp & well-scaled using the nouveau driver, but when I services.xserver.videoDrivers = ["nvidia"] , objects are drawn much too large & fuzzy. I’m seeking suggestions or how to convince the nvidia driver to run with the better resolution that I see under 20.03 with nvidia, & 21.05 with nouveau.

Sadly, I need to use nvidia due to a long-standing feature in nouveau (or the kernel?) in which my display will not wake up after a suspend. This is exhibited in many distros, not just nixos (discovered back when I was distro hopping before settling into nixos).

Possibly related: when booting under nouveau, I notice that the monitor switches to a framebuffer partway through, though not with nvidia.

In the xrandr outputs below, both say I’m running 1920x1080, so I’m confused what’s going on. The several additional resolutions under nouveau show up “System Settings | Display and Monitor | Display Configuration”. Perhaps the difference in “minimum” (8x8 vs 320x200) is meaningful, but I haven’t found any doc as to what that means.

nvidia$ xrandr
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384
HDMI-0 disconnected (normal left inverted right x axis y axis)
DP-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1920x1080     60.01*+
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 disconnected (normal left inverted right x axis y axis)

nouveau$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1920x1080     60.01*+
   1680x1050     60.00
   1400x1050     60.00
   1280x1024     59.95
   1280x960      59.99
   1152x864      59.97
   1024x768      59.95
   800x600       59.96
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)

nouveau$ neofetch --stdout | grep GPU
GPU: NVIDIA GeForce GTX 970M

Any insight as to why I’m seeing sub-optimal behavior from the nvidia driver, and what I can do to improve it?

nouveau:

nvidia:

analog issue


looks to be related KDE applications over-scaled on HiDPI display · Issue #96055 · NixOS/nixpkgs · GitHub

Through just bashing away at trying anything that came to mind, I found a solution (or at least a workaround). My issue is addressed by adding the following to my configuration.nix:

  services.xserver.dpi = 96;
  environment.variables = {
    GDK_SCALE = "0.5";
  };

One promising lead that didn’t pan out was System Settings | Display Configuration | Global Scale: in my case it needs to be set to 50%, yet the GUI doesn’t allow settings below 100%.

I should note that I confirmed the problem isn’t specific to nixos: it shows up in KDE Neon, as well as Pop OS running KDE. (Interestingly, the Pop OS gnome desktop looks fine - just seems to be a quirk with KDE combined with nvidia - at least on my hardware.) I couldn’t find a way to address the issue in Pop OS (I tried .xinit, .xserverrc, /etc/profile.d/, etc.), but didn’t spend a whole lot of time on it since that was just a test anyway.

In hindsight, I should have noticed that not everything was scaled wrong, and thus it wasn’t simply a problem with scaling on the entire monitor, but instead just on some of the objects being drawn. Specifically, in the 2 images above, notice the white dot in the background desktop image, just above the terminal’s upper left corner. That shows the background was drawn the same, and the terminal size was the same, while the text within the terminal wasn’t scaled correctly.

2 Likes