Adding Video Resolution Options

Hi! I recently installed NixOS using the GUI live boot image and am really liking it. I have one issue though with my resolution. In KDE, when I go to change my screen resolution I only see one option, 1920x1080. I would like to add a few more options.

In the past I’ve done this by updating the Xorg config, but I was wondering if there was a NixOS-specific way of doing this that plays better with the distribution. Are there options I should add to configuration.nix or should I add resolutions the old fashioned way?

Here’s my video card:

└❯ lspci | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (Whiskey Lake) (rev 02)

Assuming that you’re using an X rather than a wayland session, take a look whether there’s an option for adding resolutions at NixOS Search - Loading.... If not, you should use the services.xserver.extraConfig field to add whatever config lines you need.

As a general tip, you should NEVER edit config files on NixOS manually, because they’re supposed to be generated by Nix. Messing with them will lead to fun effects, ranging from your changes being undone by a nixos-rebuild to Nix generating parts of the config which conflict with your changes. If an option you need is missing, instead look whether there’s an extraConfig field offered for that service which you can make use of.

1 Like

This is excellent advice @casept, thank you! I’m very new to this way of thinking about admining a Linux system and I’m still trying to get the hang of it.

Here’s what I ended up doing. I checked out the config options for xwindows and xrandr and didn’t see any that specifically would call the xrandr commands that I wanted to call. I therefore tried looking through some other people’s NixOS configs but also didn’t find what I needed. I therefore just solved things by running this script on startup:

It’s not a NixOS-specific fix but it’s good enough for now.

Thanks again!

1 Like