Journal 2022-07-02

Hi, Ive been following the topic for a while, trying to fix the crash on with sync (not reverse prime). I managed to make it work with the following config:

Video config configuration.nix

<details title="video-configuration.nix">
{ config
, pkgs
, lib
, ...
}: {
  config = {
    services.xserver.exportConfiguration = true;

    services.xserver.videoDrivers = [
      # "modesetting"
      # "fbdev"
      "amdgpu"
      "nvidia"
    ];

    hardware.opengl = {
      enable = true;

      extraPackages = with pkgs; [
        rocm-opencl-icd
        rocm-opencl-runtime
        amdvlk
        vaapiVdpau
      ];

      driSupport = true;
    };


    hardware.nvidia = {
      #powerManagement = {
      #  enable = true;
      #  finegrained = true;
      #};

      nvidiaPersistenced = true;

      modesetting.enable = true;

      prime = {
        #offload.enable = true;
        sync.enable = true;

        amdgpuBusId = "PCI:5:0:0";
        nvidiaBusId = "PCI:1:0:0";
      };
    };

    environment.etc."X11/xorg.conf.d/10-amdgpu.conf".text = ''
      Section "OutputClass"
          Identifier "AMDgpu"
          MatchDriver "amdgpu"
          Driver "amdgpu"
      EndSection
    '';

    environment.etc."X11/xorg.conf.d/10-radeon.conf".text = ''
      Section "OutputClass"
          Identifier "Radeon"
          MatchDriver "radeon"
          Driver "radeon"
      EndSection
    '';

    environment.etc."X11/xorg.conf.d/10-nvidia.conf".text = ''
      Section "OutputClass"
          Identifier "nvidia"
          MatchDriver "nvidia-drm"
          Driver "nvidia"
          Option "AllowEmptyInitialConfiguration"
          Option "SLI" "Auto"
          Option "BaseMosaic" "on"
      EndSection

      Section "ServerLayout"
          Identifier "layout"
          Option "AllowNVIDIAGPUScreens"
      EndSection
    '';

    services.xserver.config = lib.mkForce ''
      Section "ServerFlags"
        Option "AllowMouseOpenFail" "on"
        Option "DontZap" "on"
      EndSection

      Section "Module"
      EndSection

      Section "Monitor"
        Identifier "Monitor[0]"
      EndSection

      # Additional "InputClass" sections
      Section "InputClass"
        Identifier "libinput mouse configuration"
        MatchDriver "libinput"
        MatchIsPointer "on"
        Option "AccelProfile" "adaptive"
        Option "LeftHanded" "off"
        Option "MiddleEmulation" "on"
        Option "NaturalScrolling" "off"
        Option "ScrollMethod" "twofinger"
        Option "HorizontalScrolling" "on"
        Option "SendEventsMode" "enabled"
        Option "Tapping" "on"
        Option "TappingDragLock" "on"
        Option "DisableWhileTyping" "off"
      EndSection

      Section "InputClass"
        Identifier "libinput touchpad configuration"
        MatchDriver "libinput"
        MatchIsTouchpad "on"
        Option "AccelProfile" "adaptive"
        Option "LeftHanded" "off"
        Option "MiddleEmulation" "on"
        Option "NaturalScrolling" "off"
        Option "ScrollMethod" "twofinger"
        Option "HorizontalScrolling" "on"
        Option "SendEventsMode" "enabled"
        Option "Tapping" "on"
        Option "TappingDragLock" "on"
        Option "DisableWhileTyping" "off"
      EndSection

      Section "ServerLayout"
        Identifier "Layout[all]"
        Inactive "Device-amdgpu[0]"

        # Reference the Screen sections for each driver.  This will
        # cause the X server to try each in turn.
        Screen "Screen-nvidia[0]"
        Screen "Screen-amdgpu[0]"
      EndSection

      # For each supported driver, add a "Device" and "Screen"
      # section.
      Section "Device"
        Identifier "Device-nvidia[0]"
        Driver "nvidia"
        BusID "PCI:1:0:0"
      EndSection

      Section "Screen"
        Identifier "Screen-nvidia[0]"
        Device "Device-nvidia[0]"
        Option "RandRRotation" "on"
        Option "AllowEmptyInitialConfiguration"
      EndSection

      Section "Screen"
        Identifier "Screen-amdgpu[0]"
        Device "Device-amdgpu[0]"
      EndSection


      Section "Device"
        Identifier "Device-amdgpu[0]"
        Driver "amdgpu"
        BusID "PCI:5:0:0"
      EndSection
    '';

    services.xserver.displayManager.gdm.wayland = false;

  };
}
</details>

Exported xorg.conf

<details title="xorg.conf">
Section "Files"

  FontPath "/nix/store/qydzz8v6nl5n88aabc2glrayy3wd867q-unifont-14.0.04/share/fonts"
  FontPath "/nix/store/23bir9f496d3q7z7r11l0139afm58ln3-font-cursor-misc-1.0.3/lib/X11/fonts/misc"
  FontPath "/nix/store/zxg8rdv42bqs5rz4p7wwsdq9dlnp8qdp-font-misc-misc-1.1.2/lib/X11/fonts/misc"
  FontPath "/nix/store/srf487s27nqn8vxxyv9jw9sl9fqif6b0-font-adobe-100dpi-1.0.3/lib/X11/fonts/100dpi"
  FontPath "/nix/store/jsysicgm3ifrjzgvpwby4v9vsph3wkm8-font-adobe-75dpi-1.0.3/lib/X11/fonts/75dpi"
  ModulePath "/nix/store/bji361pzh9knqbs182g0jgm22nw9wkgh-xf86-video-amdgpu-21.0.0/lib/xorg/modules/drivers"
  ModulePath "/nix/store/bji361pzh9knqbs182g0jgm22nw9wkgh-xf86-video-amdgpu-21.0.0/lib/xorg/modules/drivers"
  ModulePath "/nix/store/ib2y8r7s6xj408zgg9nsplcqsvpyykk9-nvidia-x11-515.48.07-5.18.6-bin/lib/xorg/modules/drivers"
  ModulePath "/nix/store/ib2y8r7s6xj408zgg9nsplcqsvpyykk9-nvidia-x11-515.48.07-5.18.6-bin/lib/xorg/modules/extensions"
  ModulePath "/nix/store/mjn47cwnwgy49zlcq7kv66smsy7r6ghv-xorg-server-1.20.14/lib/xorg/modules"
  ModulePath "/nix/store/mjn47cwnwgy49zlcq7kv66smsy7r6ghv-xorg-server-1.20.14/lib/xorg/modules/drivers"
  ModulePath "/nix/store/mjn47cwnwgy49zlcq7kv66smsy7r6ghv-xorg-server-1.20.14/lib/xorg/modules/extensions"
  ModulePath "/nix/store/mrpw1zy65avf761yydyl5v2ya1247rs8-xf86-input-evdev-2.10.6/lib/xorg/modules/input"
  ModulePath "/nix/store/cgrphl8qib783yp1g3xifsqv8bvksgsw-xf86-input-libinput-1.2.0/lib/xorg/modules/input"
FontPath "/nix/store/f741iiyrs9dj9rf5nzx0r33gfic0jd1f-X11-fonts/share/X11/fonts"

EndSection

Section "ServerFlags"
  Option "AllowMouseOpenFail" "on"
  Option "DontZap" "on"
EndSection

Section "Module"
EndSection

Section "Monitor"
  Identifier "Monitor[0]"
EndSection

# Additional "InputClass" sections
Section "InputClass"
  Identifier "libinput mouse configuration"
  MatchDriver "libinput"
  MatchIsPointer "on"
  Option "AccelProfile" "adaptive"
  Option "LeftHanded" "off"
  Option "MiddleEmulation" "on"
  Option "NaturalScrolling" "off"
  Option "ScrollMethod" "twofinger"
  Option "HorizontalScrolling" "on"
  Option "SendEventsMode" "enabled"
  Option "Tapping" "on"
  Option "TappingDragLock" "on"
  Option "DisableWhileTyping" "off"
EndSection

Section "InputClass"
  Identifier "libinput touchpad configuration"
  MatchDriver "libinput"
  MatchIsTouchpad "on"
  Option "AccelProfile" "adaptive"
  Option "LeftHanded" "off"
  Option "MiddleEmulation" "on"
  Option "NaturalScrolling" "off"
  Option "ScrollMethod" "twofinger"
  Option "HorizontalScrolling" "on"
  Option "SendEventsMode" "enabled"
  Option "Tapping" "on"
  Option "TappingDragLock" "on"
  Option "DisableWhileTyping" "off"
EndSection

Section "ServerLayout"
  Identifier "Layout[all]"
  Inactive "Device-amdgpu[0]"

  # Reference the Screen sections for each driver.  This will
  # cause the X server to try each in turn.
  Screen "Screen-nvidia[0]"
  Screen "Screen-amdgpu[0]"
EndSection

# For each supported driver, add a "Device" and "Screen"
# section.
Section "Device"
  Identifier "Device-nvidia[0]"
  Driver "nvidia"
  BusID "PCI:1:0:0"
EndSection

Section "Screen"
  Identifier "Screen-nvidia[0]"
  Device "Device-nvidia[0]"
  Option "RandRRotation" "on"
  Option "AllowEmptyInitialConfiguration"
EndSection

Section "Screen"
  Identifier "Screen-amdgpu[0]"
  Device "Device-amdgpu[0]"
EndSection


Section "Device"
  Identifier "Device-amdgpu[0]"
  Driver "amdgpu"
  BusID "PCI:5:0:0"
EndSection
</details>

Im on nixpkgs unstable with the latest kernel. The thing I noticed trying to fix the crash were:

Im not sure whether this is the cause of the crash, but I think the problem lies in how the dependencies and the final xorg.conf is generated.

<!-- Morning --> <!-- What do I want to do today? --> <!-- Evening --> <!-- What did I learn today? --> <!-- Things I learned --> <!-- Useful tools and libraries -->