hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
19.53k stars 818 forks source link

Hyprland fails to start on NixOS with NVIDIA GTX 1070 Ti #6708

Open ByteAssembler opened 2 months ago

ByteAssembler commented 2 months ago

Regression?

No

System Info and Version

System Information:

Relevant Configuration: Here are the NVIDIA-related configurations in my configuration.nix:

{ config, pkgs, ... }:

{
  # ...

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

    extraPackages = with pkgs; [
      vaapiVdpau
      libvdpau-va-gl
      nvidia-vaapi-driver
    ];
  };

  hardware.nvidia = {
    #prime = {
    #  sync.enable = true;
    #  amdgpuBusId = "PCI:006:00:0";
    #  nvidiaBusId = "PCI:007:00:0";
    #};

    package = config.boot.kernelPackages.nvidiaPackages.stable;
    open = false;
    nvidiaSettings = true;
    modesetting.enable = true;
    #nvidiaPersistenced = true;
    powerManagement.enable = false;
  };

  #boot.kernelParams = [ "nvidia-drm.modeset=1" "video=HDMI-A-1:1920x1080@60" ];

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

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the Desktop Environment.
  services.xserver.displayManager.lightdm.enable = true;
  services.xserver.desktopManager.cinnamon.enable = true;

  programs.hyprland.enable = true;
  programs.hyprland.xwayland.enable = true;

  /*
  environment.sessionVariables = {
    WLR_NO_HARDWARE_CURSORS = "1";
    NIXOS_OZONE_WL = "1";
    GBM_BACKEND = "nvidia-drm";
    __GLX_VENDOR_LIBRARY_NAME = "nvidia";
    LIBVA_DRIVER_NAME = "nvidia";
    WLR_RENDERER = "vulkan";
    XDG_SESSION_TYPE = "wayland";
    QT_QPA_PLATFORM = "wayland";
    QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
    GDK_BACKEND = "wayland";
    WLR_BACKEND = "vulkan";
  };
  */

  environment.systemPackages = with pkgs; [
    # ...
    nvidia-vaapi-driver
    egl-wayland
  ];

  system.stateVersion = "24.05";
}

Description

Hello Hyprland team,

I'm encountering an issue where Hyprland fails to start on my NixOS system. I've tried various configurations but haven't been able to resolve the problem. I would greatly appreciate any guidance or assistance you could provide. Here are the details:

Issue Description: When attempting to start Hyprland, it immediately crashes.

Error Message:

[CRITICAL] m_sWLRBackend was NULL! This usually means wlroots could not find a GPU or encountered some issues.
[CRITICAL] Critical error thrown: wlr_backend_autocreate() failed!

I've reviewed the documentation and tried the suggested solutions, but I'm still encountering this issue. If there's any additional information I can provide to help diagnose the problem, please let me know.

Thank you for your time and assistance. I appreciate the work you're doing on Hyprland and look forward to being able to use it.

How to reproduce

Steps to Reproduce:

  1. Boot into NixOS
  2. Attempt to start Hyprland session

Additional Information:

Crash reports, logs, images, videos

Crash report: hyprlandCrashReport1701.txt

Crash report - the most important: Here's the relevant part of the Hyprland crash report:

[LOG] Creating the EventLoopManager!
[LOG] Creating the HookSystem!
[LOG] Creating the KeybindManager!
[LOG] Creating the AnimationManager!
[LOG] Creating the ConfigManager!
[LOG] Creating the CHyprError!
[LOG] Creating the LayoutManager!
[LOG] Creating the TokenManager!
[LOG] Creating the PointerManager!
[backend/backend.c:105] Timeout waiting session to become active
[backend/backend.c:407] Failed to start a DRM session
[CRITICAL] m_sWLRBackend was NULL! This usually means wlroots could not find a GPU or encountered some issues.
[CRITICAL] Critical error thrown: wlr_backend_autocreate() failed!

lspci (VGA):

lspci | grep VGA
07:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070 Ti] (rev a1)

lsmod for nvidia:

$ lsmod | grep nvidia

nvidia_drm            122880  4
nvidia_modeset       1605632  7 nvidia_drm
nvidia_uvm           6635520  0
video                  77824  2 asus_wmi,nvidia_modeset
backlight              28672  3 video,asus_wmi,nvidia_modeset
nvidia              60497920  107 nvidia_uvm,nvidia_modeset
firmware_class         57344  14 r8169,mt792x_lib,ccp,btrtl,snd_hda_intel,xhci_pci_renesas,btmtk,nvidia,btintel,btbcm,btusb,mt7921_common,mt76_connac_lib,cfg80211

journalctl for hyprland:

$ journalctl -b | grep -i hyprland
Jun 29 18:03:13 WorkStation xsession[1701]: Hyprland has crashed :( Consult the crash report at /home/oreo/.cache/hyprland/hyprlandCrashReport1701.txt for more information.
Jun 29 18:03:14 WorkStation systemd-coredump[1731]: Process 1701 (.Hyprland-wrapp) of user 1000 dumped core.
                                                    Module .Hyprland-wrapped without build-id.
                                                    #3  0x00000000005c07f4 _Z25handleUnrecoverableSignali (.Hyprland-wrapped + 0x1c07f4)
                                                    #12 0x0000000000535c42 _Z10throwErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold (.Hyprland-wrapped + 0x135c42)
                                                    #13 0x00000000005d13db _ZN11CCompositor10initServerEv (.Hyprland-wrapped + 0x1d13db)
                                                    #14 0x0000000000583e10 main (.Hyprland-wrapped + 0x183e10)
                                                    #17 0x00000000005c0635 _start (.Hyprland-wrapped + 0x1c0635)
                                                    #2  0x00000000006e907d _ZNSt6thread11_State_implINS_8_InvokerISt5tupleIJZN9CWatchdogC4EvEUlvE_EEEEE6_M_runEv (.Hyprland-wrapped + 0x2e907d)
vaxerski commented 2 months ago

does sway work? or any other wayland session?

This looks like an nvidia issue anyways. @fufexan for nix though

ByteAssembler commented 2 months ago

Cinnamon (experimental) runs under Wayland on the system. Sway, on the other hand, has similar problems to Hyprland.

sifmelcara commented 2 months ago

Have you tried hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta;?

ByteAssembler commented 2 months ago

Yes, I've tried that too. I tried different nix channels and also different Linux kernels, but Hyprland would never start.

sifmelcara commented 2 months ago

Try this config and if it still does not work for you maybe try create a NixOS live CD and boot from it? The iso built from this config does work on my 1080 Ti machine (many options here are probably not required)

Save this as flake.nix and run nix build .#nixosConfigurations.hyprlandIso.config.system.build.isoImage

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };
  outputs = inputs @ { self, nixpkgs, home-manager }: {
    nixosConfigurations.hyprlandIso = nixpkgs.lib.nixosSystem rec {
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
      };
      modules = [
        ("${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-base.nix")
        ("${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix")
        ({ pkgs, config, ... }: {
          boot.kernelParams = [ "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ];
          hardware.nvidia = {
            powerManagement.enable = true;
            open = false;
            modesetting.enable = true;
            package = config.boot.kernelPackages.nvidiaPackages.beta;
          };
          services.xserver = {
            enable = true;
            videoDrivers = [ "nvidia" ];
          };
          services.displayManager = {
            sddm.enable = true;
            sessionPackages = [ pkgs.hyprland ];
          };
        })
        home-manager.nixosModules.home-manager
        {
          home-manager.useGlobalPkgs = true;
          home-manager.useUserPackages = true;
          home-manager.users.nixos = {
            imports = [ ];
            wayland.windowManager.hyprland = {
              enable = true;
              xwayland.enable = true;
              systemd.enable = true;
              extraConfig = ''
                misc {
                  vfr=off
                }
              '';
            };
            home.sessionVariables = {
              GBM_BACKEND = "nvidia-drm";
              LIBSEAT_BACKEND = "logind";
              LIBVA_DRIVER_NAME = "nvidia";
              QT_QPA_PLATFORM = "wayland";
              WLR_NO_HARDWARE_CURSORS = "1";
              XDG_SESSION_TYPE = "wayland";
              __GLX_VENDOR_LIBRARY_NAME = "nvidia";
              __GL_GSYNC_ALLOWED = "1";
            };
            home.stateVersion = "24.05";
          };
        }
      ];
    };
  };
}
ByteAssembler commented 2 months ago

Thank you so much for your detailed suggestion and the NixOS configuration, @sifmelcara. I really appreciate your effort to help me troubleshoot this issue. I've followed your recommendations, and here's what I've found:

1. Existing NixOS Configuration: I integrated your provided configuration into my current NixOS setup. After restarting, I was able to see the SDDM login screen. However, when I attempted to log in, nothing happened. (The hyprland logs show the same error as before.)

2. ISO Build: Following your recommendation, I proceeded to build the ISO using the provided flake.nix. The build process completed without any errors. For reference, the SHA-256 hash of the resulting ISO is (https://github.com/NixOS/nixpkgs/tree/8f48c9241de143e8e60a826d405fa8dec5e49343):

 7fe21509a7ed28e3e1909e6d555df332f6f2345ddb41df3104e93a15b04f29c3

It would be helpful to know if this hash matches what you'd expect, as it could confirm whether the ISO was built correctly.

3. Booting from ISO: Unfortunately, when I tried to boot from this ISO, I encountered a black screen. On one of my monitors, I could see the backlight, while the others remained “off” (actually as before). I suspect this might be because the login screen is typically skipped during live boot, and Hyprland may have failed to start again, similar to my previous attempts.

Since this was a live system, I don't have logs from this boot process. However, I believe the underlying issue might be the same as what I've been experiencing before.

I must admit, I'm feeling a bit disheartened at this point. I'm wondering if there might be some underlying issue with my NixOS configuration or perhaps some hardware-specific problem that we haven't identified yet.

I'm particularly intrigued that this configuration works on your system with a NVIDIA GTX 1080 Ti. This makes me think that there must be some critical difference between our setups. While I don't believe it's related to my CPU (I'm using an AMD Ryzen), at this point, I'm open to considering all possibilities.

Do you have any thoughts on what might be causing this persistent issue? Are there any additional logs or system information I could provide that might help pinpoint the problem?

Despite the setbacks, I would like to continue trying to get Hyprland to work on my system. If you have any suggestions or need additional information, please let me know.

Thank you for your assistance.

sifmelcara commented 2 months ago

I suspect this might be because the login screen is typically skipped during live boot, and Hyprland may have failed to start again, similar to my previous attempts

It should show sddm login screen first. User will need to type password ("nixos") to log into Hyprland session.

On one of my monitors, I could see the backlight, while the others remained “off” (actually as before)

I have 3 monitors plugging into nvidia card and they all shows sddm login screen and Hyprland properly

While I don't believe it's related to my CPU (I'm using an AMD Ryzen)

FWIW I have Intel CPU

Do you have any thoughts on what might be causing this persistent issue? Are there any additional logs or system information I could provide that might help pinpoint the problem?

It sounds like you have multiple monitors, maybe try using single HDMI monitor first?

Have you ever update NVIDIA firmware? My card have https://www.nvidia.com/en-us/drivers/nv-uefi-update-x64/ applied, and I feel this could be relevant to your "black screen" issue.

GameDungeon commented 2 months ago

This sounds like this nvidia issue I am seeing reports a lot of reports of. I would say downgrade the NVIDIA drivers. https://forums.developer.nvidia.com/t/555-release-feedback-discussion/293652/173

Starnick4444 commented 1 month ago

I've had a very similar crash message, and managed to solve it by setting WLR_DRM_DEVICES. Followed this comment https://github.com/hyprwm/Hyprland/issues/2622#issuecomment-1616067379, In my case /dev/dri/card0 was pointing to simple-framebuffer, and card1 was the correct one.

izmyname commented 1 month ago

Is this still a thing?