No screens found by X in WSL

Hi,

I’m trying to get X and ideally XMonad running on NixOS WSL.

I’ve been following the official docs and I’ve added the following lines to my configuration.nix:

  services.xserver.enable = true;
  services.xserver.windowManager.xmonad = {
    enable = true;
    enableContribAndExtras = true;
  };

When trying to run sudo systemctl start display-manager.service I get this error:

Jul 21 17:23:21 nixos systemd[1]: display-manager.service: Main process exited, code=exited, status=1/FAILURE
Jul 21 17:23:21 nixos systemd[1]: display-manager.service: Failed with result 'exit-code'.
Jul 21 17:23:21 nixos systemd[1]: display-manager.service: Triggering OnFailure= dependencies.
Jul 21 17:23:21 nixos systemd[1]: display-manager.service: Failed to enqueue OnFailure= job, ignoring: Unit plymouth-quit.service not found.
Jul 21 17:23:22 nixos systemd[1]: display-manager.service: Scheduled restart job, restart counter is at 1.

I searched this forum and it seems this plymouth-quit service not being found is kind of a generic error for when something goes wrong with booting X. My laptop has two graphics cards, so maybe that is causing issues? I tried setting the graphics driver to Intel, but no joy.

cat /var/log/Xorg.1.log gives:

<snip>
[  1462.420] (II) The server relies on udev to provide the list of input devices.
        If no devices become available, reconfigure udev or disable AutoAddDevices.
[  1462.420] (II) Loader magic: 0x640e40
[  1462.420] (II) Module ABI versions:
[  1462.420]    X.Org ANSI C Emulation: 0.4
[  1462.420]    X.Org Video Driver: 25.2
[  1462.420]    X.Org XInput driver : 24.4
[  1462.420]    X.Org Server Extension : 10.0
[  1462.420] (--) using VT number 1

[  1462.420] (II) systemd-logind: logind integration requires -keeptty and -keeptty was not provided, disabling logind integration
[  1462.420] (II) xfree86: Adding drm device (/dev/dri/card0)
[  1462.420] (II) Platform probe for /sys/devices/platform/vgem/drm/card0
[  1462.425] (--) PCI: (0@43518:0:0) 1414:008e:0000:0000 rev 0
[  1462.425] (--) PCI: (0@57132:0:0) 1414:008e:0000:0000 rev 0
[  1462.425] (II) no primary bus or device found
[  1462.425]    falling back to /sys/devices/platform/vgem/drm/card0
[  1462.425] (WW) Open ACPI failed (/var/run/acpid.socket) (No such file or directory)
[  1462.425] (II) LoadModule: "glx"
[  1462.425] (II) Loading /nix/store/xq4plra9l5a3p7ginab2cdkmzcsvfvcv-xorg-server-21.1.13/lib/xorg/modules/extensions/libglx.so
[  1462.426] (II) Module glx: vendor="X.Org Foundation"
[  1462.426]    compiled for 1.21.1.13, module version = 1.0.0
[  1462.426]    ABI class: X.Org Server Extension, version 10.0
[  1462.426] (==) Matched modesetting as autoconfigured driver 0
[  1462.426] (==) Matched fbdev as autoconfigured driver 1
[  1462.426] (==) Matched vesa as autoconfigured driver 2
[  1462.426] (==) Assigned the driver to the xf86ConfigLayout
[  1462.426] (II) LoadModule: "modesetting"
[  1462.426] (II) Loading /nix/store/xq4plra9l5a3p7ginab2cdkmzcsvfvcv-xorg-server-21.1.13/lib/xorg/modules/drivers/modesetting_drv.so
[  1462.426] (II) Module modesetting: vendor="X.Org Foundation"
[  1462.426]    compiled for 1.21.1.13, module version = 1.21.1
[  1462.426]    Module class: X.Org Video Driver
[  1462.426]    ABI class: X.Org Video Driver, version 25.2
[  1462.426] (II) LoadModule: "fbdev"
[  1462.426] (WW) Warning, couldn't open module fbdev
[  1462.426] (EE) Failed to load module "fbdev" (module does not exist, 0)
[  1462.426] (II) LoadModule: "vesa"
[  1462.426] (WW) Warning, couldn't open module vesa
[  1462.426] (EE) Failed to load module "vesa" (module does not exist, 0)
[  1462.426] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[  1462.426] (WW) Falling back to old probe method for modesetting
[  1462.426] (WW) Falling back to old probe method for modesetting
[  1462.426] (EE) No devices detected.
[  1462.426] (EE)
Fatal server error:
[  1462.426] (EE) no screens found(EE)
[  1462.426] (EE)
Please consult the The X.Org Foundation support
         at http://wiki.x.org
 for help.
[  1462.426] (EE) Please also check the log file at "/var/log/Xorg.1.log" for additional information.
[  1462.426] (EE)
[  1462.426] (EE) Server terminated with error (1). Closing log file.

So it seems X fails to find any suitable devices. What’s going wrong here, from what I could find on google, I don’t need anyting special to detect devices on WSL, but maybe I’m missing something?

Which docs are those?

https://nixos.org/manual/nixos/stable/#sec-x11

I was never running a full DE in WSL but for version 1 I used an X server installed on windows and forwarded specific apps to it. For version 2, I dont need to run the X server to execute GUI apps.
I’m not sure WSL works the way you want.

You can not use you own X server under WSL, because the VM it runs in does not have a display attached. The way WSLg works is, that WSL provides a Wayland server (and Wayland for Xorg compatibility) in a separate container (called the “System Distribution”) which is then mounted into your actual distro’s container. Because this uses Wayland, you won’t be able to use your own window manager with it, only the one provided by WSL (Weston)

What you could try (though I don’t know if it will be a usable experience) is running a nested X server like Xephyr and start Xmonad inside of that:

Xephyr :1 - screen 1280x720 & # or -fullscreen
xmonad

(Xephyr is in the package xorg.xorgserver)

Thanks for the explanation. That makes sense. I was wondering how this could work nicely with Windows :D.

Do you have any links for setting up Wayland with Weston in NixOS?

I will try the method you suggest also, but I’m happy to keep things simple since it sounds like WSL has some limitations.

Perhaps it’s simpler to just go the old route and dual boot, but I was hoping to avoid that if I can.

In theory, Wayland should just work. Just start some GUI application

Ah thanks so much! Wayland did indeed just work. I should have tried that before :P.