Desktop nvidia tty / console resolution

Hi there.

I have a new setup (pc amd cpu + nvidia gpu, hybrid disabled) and I’m new to NixOS.
My goal is to have a working configuration using Wayland + Hyprland and a greeter (probably greetd + gtkgreet, currently sddm). The system is connected to one screen with the resolution 3840x1600@144 using displayport.

My only issue I can’t solve is the tty / console resolution. It’s fixed to 1024x768 and I can’t figure out how to change it. The resolution is the same during the boot and within the tty(s) afterwards.

I don’t have any console / font setup yet, staying to the defaults.

I tried to enable the nvidia module during the boot, but this doesn’t change anything:

boot.initrd.kernelModules = [ "nvidia" ];   

I tried to set the resolution using

 boot.kernelParams = [ "video=3840x1600" ];

The boot starts with

 initrd=\EFI\nixos\3p5v5d67zvdfa8kydzzh9y3ycdasf1qx-initrd-linux-6.6.31-initrd.efi init=/nix/store/p2xi92b6s6hffi1psi0nnzkwzk9mc9vr-nixos-system-nix-24.11.20240524.bfb7a88/init video=3840x1600 loglevel=4 nvidia-drm.modeset=1

but the mode fails with

[    0.645872] simple-framebuffer simple-framebuffer.0: [drm] User-defined mode not supported: "3840x1600": 60 522915 3840 4128 4552 5264 1600 1601 1604 1656 0x20 0x6

(I also tried adding @144)

How could I set the correct resolution?

Also relevant might be:

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.timeout = 2;
  boot.loader.systemd-boot.consoleMode = "max";

...

  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };

  services.xserver = {
    videoDrivers = ["nvidia"];
  };

  hardware.nvidia = {
    modesetting.enable = true;
    open = false;
    powerManagement.enable = false;
    powerManagement.finegrained = false;
    nvidiaSettings = true;
    package = config.boot.kernelPackages.nvidiaPackages.stable;
  };

I tried different consoleModes without any effect.

console ={
  earlySetup = true;
};

Didn’t change anything either.

My hardware config:

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "nvme" "ahci" "xhci_pci" "usbhid" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-amd" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-label/NIXROOT";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-label/NIXBOOT";
      fsType = "vfat";
      options = [ "fmask=0022" "dmask=0022" ];
    };

  swapDevices = [ ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp12s0.useDHCP = lib.mkDefault true;
  # networking.interfaces.wlp13s0.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

I’m thankful for any suggestions as I’m out of ideas…
Thanks for your help :slight_smile:

Christian

1 Like

I had the same problems after installing nVidia drivers. Following these instructions, I disabled CSM (Legacy Boot), and it solved my problems, although it also made everything before Stage 1 really, really small… Hope it helps.

I am not 100% sure, but I think setting boot.kernelParams = [ "nvidia-drm.fbdev=1" ]; will help. I still need to figure out what this actually does…

This is awesome thank you!
The resolution looks correct now using this kernel parameter, but the tty doesn´t fill the entire screen (4k screen). It’s stuck at 1920x1080, which makes the top left quarter of my 4k resolution. Do you have any idea how to increase the actual tty resoultion?

Dang, this seems like a complicated issue looking at:

And:

It seems like setting hardware resolution in kernel parameters is not recommended and also not supported for nvidia. Although, my 2k monitor with nvidia does not have this issue and just works.

Maybe you can try manually adjusting the resolution like the threads I linked suggest?

I think the next best thing is link you to my host configuration and play spot-the-difference:

I also use nixos-hardware, which provides sensible defaults for stuff like this:

There are of course people with far better nvidia hardware configurations, so I highly suggest using GitHub search for “language:nix nvidia” and seeing what you come up with.

Thanks a lot for your help!
The resolution is still fixed to 1920x1080, which is the only supported mode for me:

cat /sys/class/graphics/fb0/modes

U:1920x1080p-0

Using the framebuffer device provided by the nvidia driver package helps with not stretching this resolution to the 4k screen, which looks kind of horrible :wink: so this is a win for me.

hwinfo --framebuffer

doesn´t provide any info (I guess it’s not supported for the nvidia fbdev).

I also have a dummy plug connected to hdmi (my screen is using displayport) which has the 1080p resolution, probable this is why the fbdev selects this resolution as the proper one, even though it’s using the 4k screen connected to DP.

1 Like