Setting up X in NixOS with AMD Radeon 6800

I have been trying for a while to set up my NixOS configuration in my new PC, and the main setback I have found is that I am unable to properly configure the X server (and, I guess, the graphics card itself!). I am using an AMD Radeon 6800 which is a fairly new card, so I was expecting these kind of issues.

The main issue is that I cannot start a display manager or anything like that because X fails with “Can’t open display”. For now, I have followed the basic steps in the wiki page and I have added:

boot.initrd.kernelModules = [ "amdgpu" ];
services.xserver.videoDrivers = [ "amdgpu" ];

But I still find the same error. I have never owned an AMD card so I don’t know if there are any more quirks I am not aware of. I am a newbie in this topic so any help is super valuable. Has anyone found a working configuration with a similar card? Thanks in advance!

Hi,
these new navi21 cards are only supported by LLVM 11 upwards, which is important as mesa (the graphics driver) is relying on llvm to compile any shaders. The llvm version used by mesa was updated only few weeks ago on nixos-unstable (before it was llvm 7), so if you are on 20.09, you want to use mesa from nixos-unstable.
I hope this helps.

Edit: Something like this should work (from this post):

{ pkgs, config, ... }:

let
  unstablepkgs = import <nixpkgs-unstable> {};
in {
  hardware.opengl = {
    enable = true;
    package = unstablepkgs.mesa.drivers;
    driSupport32Bit = true;
    package32 = unstablepkgs.pkgsi686Linux.mesa.drivers;
  };
}
2 Likes

I don’t have any special knowledge about 6800s, but the kernel version can affect these kinds of things so maybe also try:

boot.kernelPackages = pkgs.linuxPackages_latest;
3 Likes

I am having similar issues, but running nixos unstable and with a 6900XT.

I have display up until X tries to start.

I have boot.kernelPackages = pkgs.linuxPackages_latest, as well as boot.initrd.kernelModules = [ "amdgpu" ]; and services.xserver.videoDrivers = [ "amdgpu" ]; set.

My X Logs
Jan 28 12:33:59 duchess xserver-wrapper[2877]: X.Org X Server 1.20.10
Jan 28 12:33:59 duchess xserver-wrapper[2877]: X Protocol Version 11, Revision 0
Jan 28 12:33:59 duchess xserver-wrapper[2877]: Build Operating System: Linux 4.19.91 x86_64
Jan 28 12:33:59 duchess xserver-wrapper[2877]: Current Operating System: Linux duchess 5.10.10 #1-NixOS SMP Sat Jan 23 15:04:06 UTC 2021 x86_64
Jan 28 12:33:59 duchess xserver-wrapper[2877]: Kernel command line: initrd=\efi\nixos\140rqx0qhfyrr1cmpdyqj1vn12yads90-initrd-linux-5.10.10-initrd.efi systemConfig=/nix/store/9iz7mrk9mhbk5pzbgxydid3jxqh0fkys-nixos-system-duchess-21.03.20210125.891f607 init=/nix/store/9iz7mrk9mhbk5pzbgxydid3jxqh0fkys-nixos-system-duchess-21.03.20210125.891f607/init amdgpu.dc=0 loglevel=4
Jan 28 12:33:59 duchess xserver-wrapper[2877]: Build Date: 01 December 2020  04:33:29PM
Jan 28 12:33:59 duchess xserver-wrapper[2877]:
Jan 28 12:33:59 duchess xserver-wrapper[2877]: Current version of pixman: 0.38.4
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         Before reporting problems, check http://wiki.x.org
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         to make sure that you have the latest version.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: Markers: (--) probed, (**) from config file, (==) default setting,
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         (++) from command line, (!!) notice, (II) informational,
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (++) Log file: "/dev/null", Time: Thu Jan 28 12:33:59 2021
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (++) Using config file: "/nix/store/682vxh0hzrrsq7nkff1vshrdqxjiw9g8-xserver.conf"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) Using config directory: "/etc/X11/xorg.conf.d"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) Using system config directory "/nix/store/c8m6an6p6wwziliph993gzyxfzfyqp61-xorg-server-1.20.10/share/X11/xorg.conf.d"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) ServerLayout "Layout[all]"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (**) |-->Screen "Screen-amdgpu[0]" (0)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (**) |   |-->Monitor "<default monitor>"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (**) |   |-->Device "Device-amdgpu[0]"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) No monitor specified for screen "Screen-amdgpu[0]".
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         Using a default monitor configuration.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (**) Option "DontZap" "on"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (**) Option "AllowMouseOpenFail" "on"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) Automatically adding devices
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) Automatically enabling devices
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) Automatically adding GPU devices
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) Max clients allowed: 256, resource mask: 0x1fffff
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (**) FontPath set to:
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         /nix/store/0g0mi7fcq5qr884f4z7ca2k4mnh1a9bx-font-misc-misc-1.1.2/lib/X11/fonts/misc,
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         /nix/store/hpbpwxv1cgnimzyg7xqdmrinlrhajj46-font-cursor-misc-1.0.3/lib/X11/fonts/misc,
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         /nix/store/n3d3rrpbj2yhyh9ixsdf40f9lkffwgng-unifont-13.0.05/share/fonts,
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         /nix/store/05nyyky911cadhkwbwj6ss0axfafb93k-font-bh-lucidatypewriter-100dpi-1.0.3/lib/X11/fonts/100dpi,
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         /nix/store/jysh8bhi21h1ikg59pbv5chir20yxc4v-font-bh-lucidatypewriter-75dpi-1.0.3/lib/X11/fonts/75dpi,
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         /nix/store/pv66i0mzpwl4wniasc3qjwc87wdn8qlb-font-bh-100dpi-1.0.3/lib/X11/fonts/100dpi,
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         /nix/store/k414simbkwb2b712iswh965lhpr8wp59-font-adobe-100dpi-1.0.3/lib/X11/fonts/100dpi,
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         /nix/store/qjapi9jv01y78laqi2gjkscr7m444k43-font-adobe-75dpi-1.0.3/lib/X11/fonts/75dpi
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (**) ModulePath set to "/nix/store/fgbrxngda5i9jfpyhrbqqpnz8yppfm12-xf86-video-amdgpu-19.1.0/lib/xorg/modules/drivers,/nix/store/c8m6an6p6wwziliph993gzyxfzfyqp61-xorg-server-1.20.10/lib/xorg/modules,/nix/store/c8m6an6p6wwziliph993gzyxfzfyqp61-xorg-server-1.20.10/lib/xorg/modules/drivers,/nix/store/c8m6an6p6wwziliph993gzyxfzfyqp61-xorg-server-1.20.10/lib/xorg/modules/extensions,>"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) The server relies on udev to provide the list of input devices.
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         If no devices become available, reconfigure udev or disable AutoAddDevices.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Loader magic: 0x62cd40
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Module ABI versions:
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         X.Org ANSI C Emulation: 0.4
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         X.Org Video Driver: 24.1
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         X.Org XInput driver : 24.1
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         X.Org Server Extension : 10.0
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (++) using VT number 7
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) systemd-logind: logind integration requires -keeptty and -keeptty was not provided, disabling logind integration
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) xfree86: Adding drm device (/dev/dri/card0)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (--) PCI:*(10@0:0:0) 1002:73bf:1da2:e438 rev 192, Mem @ 0xe0000000/268435456, 0xf0000000/2097152, 0xfcb00000/1048576, I/O @ 0x0000e000/256, BIOS @ 0x????????/131072
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (WW) Open ACPI failed (/var/run/acpid.socket) (No such file or directory)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) "glx" will be loaded by default.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) LoadModule: "glx"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Loading /nix/store/c8m6an6p6wwziliph993gzyxfzfyqp61-xorg-server-1.20.10/lib/xorg/modules/extensions/libglx.so
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Module glx: vendor="X.Org Foundation"
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         compiled for 1.20.10, module version = 1.0.0
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         ABI class: X.Org Server Extension, version 10.0
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) LoadModule: "amdgpu"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Loading /nix/store/fgbrxngda5i9jfpyhrbqqpnz8yppfm12-xf86-video-amdgpu-19.1.0/lib/xorg/modules/drivers/amdgpu_drv.so
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Module amdgpu: vendor="X.Org Foundation"
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         compiled for 1.20.10, module version = 19.1.0
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         Module class: X.Org Video Driver
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         ABI class: X.Org Video Driver, version 24.1
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) AMDGPU: Driver for AMD Radeon:
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         All GPUs supported by the amdgpu kernel driver
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) AMDGPU(0): [KMS] Kernel modesetting enabled.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) AMDGPU(0): Depth 24, (--) framebuffer bpp 32
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) AMDGPU(0): Pixel depth = 24 bits stored in 4 bytes (32 bpp pixmaps)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) AMDGPU(0): Default visual is TrueColor
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) AMDGPU(0): RGB weight 888
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) AMDGPU(0): Using 8 bits per RGB (8 bit DAC)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (--) AMDGPU(0): Chipset: "Unknown AMD Radeon GPU" (ChipID = 0x73bf)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Loading sub module "fb"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) LoadModule: "fb"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Loading /nix/store/c8m6an6p6wwziliph993gzyxfzfyqp61-xorg-server-1.20.10/lib/xorg/modules/libfb.so
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Module fb: vendor="X.Org Foundation"
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         compiled for 1.20.10, module version = 1.0.0
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         ABI class: X.Org ANSI C Emulation, version 0.4
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Loading sub module "dri2"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) LoadModule: "dri2"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Module "dri2" already built-in
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Loading sub module "glamoregl"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) LoadModule: "glamoregl"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Loading /nix/store/c8m6an6p6wwziliph993gzyxfzfyqp61-xorg-server-1.20.10/lib/xorg/modules/libglamoregl.so
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Module glamoregl: vendor="X.Org Foundation"
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         compiled for 1.20.10, module version = 1.0.1
Jan 28 12:33:59 duchess xserver-wrapper[2877]:         ABI class: X.Org ANSI C Emulation, version 0.4
Jan 28 12:33:59 duchess xserver-wrapper[2877]: amdgpu: os_same_file_description couldn't determine if two DRM fds reference the same file description.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: If they do, bad things may happen!
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) AMDGPU(0): glamor X acceleration enabled on AMD SIENNA_CICHLID (DRM 3.40.0, 5.10.10, LLVM 11.0.1)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) AMDGPU(0): glamor detected, initialising EGL layer.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) AMDGPU(0): TearFree property default: auto
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) AMDGPU(0): VariableRefresh: disabled
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) AMDGPU(0): KMS Pageflipping: enabled
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (WW) AMDGPU(0): No outputs definitely connected, trying again...
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (WW) AMDGPU(0): Unable to find connected outputs - setting 1024x768 initial framebuffer
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) AMDGPU(0): mem size init: gart size :3fe4f9000 vram size: s:3fdbc7000 visible:fd48000
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) AMDGPU(0): DPI set to (96, 96)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (==) AMDGPU(0): Using gamma correction (1.0, 1.0, 1.0)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Loading sub module "ramdac"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) LoadModule: "ramdac"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Module "ramdac" already built-in
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (EE) AMDGPU(0): No modes.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) UnloadModule: "amdgpu"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) UnloadSubModule: "glamoregl"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Unloading glamoregl
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) UnloadSubModule: "fb"
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (II) Unloading fb
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (EE) Screen(s) found, but none have a usable configuration.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (EE)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: Fatal server error:
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (EE) no screens found(EE)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (EE)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: Please consult the The X.Org Foundation support
Jan 28 12:33:59 duchess xserver-wrapper[2877]:          at http://wiki.x.org
Jan 28 12:33:59 duchess xserver-wrapper[2877]:  for help.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (EE) Please also check the log file at "/dev/null" for additional information.
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (EE)
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (EE) Server terminated with error (1). Closing log file.

What stands out to me in the logs is the error (EE) AMDGPU(0): No modes. as well as

Jan 28 12:33:59 duchess xserver-wrapper[2877]: (WW) AMDGPU(0): No outputs definitely connected, trying again...
Jan 28 12:33:59 duchess xserver-wrapper[2877]: (WW) AMDGPU(0): Unable to find connected outputs - setting 1024x768 initial framebuffer

but the same GPU/display combo works on Windows, so I don’t think I can blame the displayport cord and monitor. I wonder if I just need to specify more configuration for X?

My current X config in nix
# Enable the X11 windowing system.
  services.xserver = {
    enable = true;
    layout = "us";
    videoDrivers = [ "amdgpu" ];
    resolutions = [{ y = 1440; x = 3440; }];
  };

Another interesting log note: AMDGPU(0): Chipset: "Unknown AMD Radeon GPU" (ChipID = 0x73bf)

which leads me to this debian bug report

Which somewhat matches the kernel I’m using (from uname -a)

Linux duchess 5.10.10 #1-NixOS SMP Sat Jan 23 15:04:06 UTC 2021 x86_64 GNU/Linux

So perhaps I need to enable this DCN option? Would that involve recompiling the kernel? Is there a nix-y way of enabling these kernel options?

@diego Enabling the DCN option worked. Adding

  boot.kernelPatches = [{
    name = "big-navi";
    patch = null;
    extraConfig = ''
      DRM_AMD_DC_DCN3_0 y
    '';
  }];

and letting my system rebuild and reboot has given me a working desktop! I will look into upstreaming this change.

Edit: PR is now up common-config: Enable RX 6000 Series AMDGPU by afontaine · Pull Request #111177 · NixOS/nixpkgs · GitHub

5 Likes