No second monitor

Hello,

I was on arch linux before and everything was working fine, I configured most of my nix config in a VM. But now that I switch my distro, nixos doesn’t detect my other monitors. This is my config :

{ config, ... }:
{
  hardware.graphics.enable = true;

  # hardware.nvidia-container-toolkit.enable = true;

  hardware.nvidia = {
    modesetting.enable = true;

    powerManagement = {
      enable = true;
      finegrained = true; # nvidia opti
    };

    # TODO : remove ?
    open = true;

    nvidiaSettings = true;
    package = config.boot.kernelPackages.nvidiaPackages.latest;

    # Disable gpu when not needed.
    # NOTE: could change this with a clamshell mode and multiple boot
    # configuration.
    prime = {
      offload = {
        enable = true;
        enableOffloadCmd = true;
      };
      nvidiaBusId = "PCI:1:0:0";
      intelBusId = "PCI:0:2:0";
    };
  };
}

...
    nix.settings = {
      substituters = [ "https://hyprland.cachix.org" ];
      trusted-public-keys = [
        "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
      ];
    };

    programs.hyprland = {
      enable = true;
      package = inputs.hyprland.packages.${pkgs.system}.hyprland;
      xwayland.enable = true;
      portalPackage =
        inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
    };

    environment.sessionVariables = {
      NIXOS_OZONE_WL = "1";
      LIBVA_DRIVER_NAME = "nvidia";
      __GLX_VENDOR_LIBRARY_NAME = "nvidia";
    };
...

Is there something wrong ? I guess it’s related to nvidia and hyprland
I also have these output :

󱞩 : sudo lshw -c display
  *-display                 
       description: i915drmfb
       physical id: 0
       bus info: pci@0000:01:00.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=2560x1600 visual=truecolor xres=2560 yres=1600
       resources: iomemory:600-5ff iomemory:620-61f memory:90000000-90ffffff memory:6000000000-61ffffffff memory:6200000000-6201ffffff ioport:3000(size=128) memory:91080000-910fffff
  *-display
       product: i915drmfb
       physical id: 2
       bus info: pci@0000:00:02.0
       logical name: /dev/fb0
       version: 04
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm bus_master cap_list rom fb
       configuration: depth=32 driver=i915 latency=0 resolution=2560,1600
       resources: iomemory:620-61f iomemory:400-3ff irq:202 memory:6250000000-6250ffffff memory:4000000000-400fffffff ioport:4000(size=64) memory:c0000-dffff memory:4010000000-4016ffffff memory:4020000000-40ffffffff
󱞩 : xrandr --query
Screen 0: minimum 16 x 16, current 2560 x 1600, maximum 32767 x 32767
eDP-1 connected 2560x1600+0+0 (normal left inverted right x axis y axis) 340mm x 220mm
   2560x1600    119.93*+
   2048x1536    119.95
...

I have two screeen, one in HDMI that should always work, and a seconc one with usb-c that I have to unplug-replug multiple times to get it work on archlinux but works fine on windows.

Edit : it seems that my GPU isn’t detected as a it and has no driver

Those happen to be the example settings, did you check what your actual bus IDs are? What does lspci say?

The wiki documents this stuff in a good amount of detail (double check you’re on the official wiki, the unofficial one is horribly outdated especially for nvidia), fyi: NVIDIA - NixOS Wiki

You might also need to set services.xserver.videoDrivers.

For checking the bus ids you could also try GitHub - eclairevoyant/pcids: Get PCI bus location IDs for video cards

nix --experimental-features "flakes nix-command" run github:eclairevoyant/pcids

Though based on the lshw output it seems correct as-is?

1 Like

Could be flipped, but yep, I overlooked that.