diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix index 1e18e927ec6..fcb30187fa2 100644 --- a/nixos/modules/hardware/video/nvidia.nix +++ b/nixos/modules/hardware/video/nvidia.nix @@ -111,9 +111,10 @@ in config = mkIf enabled { assertions = [ { - assertion = with config.services.xserver.displayManager; gdm.enable -> !gdm.wayland; - message = "NVIDIA drivers don't support wayland, set services.xserver.displayManager.gdm.wayland=false"; + assertion = with config.services.xserver.displayManager; gdm.nvidiaWayland -> cfg.modesetting.enable; + message = "You cannot use wayland with GDM without modesetting enabled for NVIDIA drivers, set `hardware.nvidia.modesetting.enable = true`"; } + { assertion = !optimusCfg.enable || (optimusCfg.nvidiaBusId != "" && optimusCfg.intelBusId != ""); diff --git a/nixos/modules/services/x11/display-managers/gdm.nix b/nixos/modules/services/x11/display-managers/gdm.nix index 0af9ccfcf3e..912ec5bd38e 100644 --- a/nixos/modules/services/x11/display-managers/gdm.nix +++ b/nixos/modules/services/x11/display-managers/gdm.nix @@ -126,11 +126,21 @@ in wayland = mkOption { default = true; description = '' - Allow GDM run on Wayland instead of Xserver + Allow GDM to run on Wayland instead of Xserver. + Note to enable Wayland with Nvidia you need to + enable the . ''; type = types.bool; }; + nvidiaWayland = mkOption { + default = false; + description = '' + Whether to allow wayland to be used with the proprietary + NVidia graphics driver. + ''; + }; + autoSuspend = mkOption { default = true; description = '' @@ -237,6 +247,19 @@ in services.dbus.packages = [ gdm ]; + # We duplicate upstream's udev rules manually to make wayland with nvidia configurable + services.udev.extraRules = '' + # disable Wayland on Cirrus chipsets + ATTR{vendor}=="0x1013", ATTR{device}=="0x00b8", ATTR{subsystem_vendor}=="0x1af4", ATTR{subsystem_device}=="0x1100", RUN+="${gdm}/libexec/gdm-disable-wayland" + # disable Wayland on Hi1710 chipsets + ATTR{vendor}=="0x19e5", ATTR{device}=="0x1711", RUN+="${gdm}/libexec/gdm-disable-wayland" + ${optionalString (!cfg.gdm.nvidiaWayland) '' + DRIVER=="nvidia", RUN+="${gdm}/libexec/gdm-disable-wayland" + ''} + # disable Wayland when modesetting is disabled + IMPORT{cmdline}="nomodeset", RUN+="${gdm}/libexec/gdm-disable-wayland" + ''; + systemd.user.services.dbus.wantedBy = [ "default.target" ]; programs.dconf.profiles.gdm = diff --git a/pkgs/desktops/gnome-3/core/mutter/default.nix b/pkgs/desktops/gnome-3/core/mutter/default.nix index 8fad9e3c288..6d36b8710b6 100644 --- a/pkgs/desktops/gnome-3/core/mutter/default.nix +++ b/pkgs/desktops/gnome-3/core/mutter/default.nix @@ -10,6 +10,7 @@ , sysprof , desktop-file-utils , libcap_ng +, egl-wayland }: stdenv.mkDerivation rec { @@ -26,6 +27,8 @@ stdenv.mkDerivation rec { mesonFlags = [ "-Dxwayland-path=${xwayland}/bin/Xwayland" "-Dinstalled_tests=false" # TODO: enable these + "-Dwayland_eglstream=true" + "-Degl_device=true" ]; propagatedBuildInputs = [ @@ -52,7 +55,7 @@ stdenv.mkDerivation rec { gnome-desktop cairo pango cogl zenity libstartup_notification geocode-glib libinput libgudev libwacom libcanberra-gtk3 zenity xkeyboard_config libxkbfile - libxkbcommon pipewire xwayland + libxkbcommon pipewire xwayland egl-wayland gnome-settings-daemon sysprof ]; diff --git a/pkgs/development/libraries/egl-wayland/default.nix b/pkgs/development/libraries/egl-wayland/default.nix new file mode 100644 index 00000000000..b8fcbfb1c76 --- /dev/null +++ b/pkgs/development/libraries/egl-wayland/default.nix @@ -0,0 +1,73 @@ +{ lib +, stdenv +, fetchFromGitHub +, pkgconfig +, meson +, ninja +, libX11 +, mesa +, wayland +}: + +let + eglexternalplatform = stdenv.mkDerivation { + pname = "eglexternalplatform"; + version = "1.1"; + + src = fetchFromGitHub { + owner = "Nvidia"; + repo = "eglexternalplatform"; + rev = "7c8f8e2218e46b1a4aa9538520919747f1184d86"; + sha256 = "0lr5s2xa1zn220ghmbsiwgmx77l156wk54c7hybia0xpr9yr2nhb"; + }; + + installPhase = '' + mkdir -p "$out/include/" + cp interface/eglexternalplatform.h "$out/include/" + cp interface/eglexternalplatformversion.h "$out/include/" + + substituteInPlace eglexternalplatform.pc \ + --replace "/usr/include/EGL" "$out/include" + mkdir -p "$out/share/pkgconfig" + cp eglexternalplatform.pc "$out/share/pkgconfig/" + ''; + + meta = with lib; { + license = licenses.mit; + }; + }; + +in stdenv.mkDerivation rec { + pname = "egl-wayland"; + version = "1.1.4"; + + outputs = [ "out" "dev" ]; + + src = fetchFromGitHub { + owner = "Nvidia"; + repo = pname; + rev = version; + sha256 = "0wvamjcfycd7rgk7v14g2rin55xin9rfkxmivyay3cm08vnl7y1d"; + }; + + nativeBuildInputs = [ + meson + ninja + pkgconfig + ]; + + buildInputs = [ + eglexternalplatform + libX11 + mesa + wayland + ]; + + meta = with lib; { + description = "The EGLStream-based Wayland external platform"; + homepage = https://github.com/NVIDIA/egl-wayland/; + license = licenses.mit; + platforms = platforms.linux; + maintainers = with maintainers; [ hedning ]; + }; +} diff --git a/pkgs/servers/x11/xorg/xwayland.nix b/pkgs/servers/x11/xorg/xwayland.nix index 06f54fd5207..d033f211c3a 100644 --- a/pkgs/servers/x11/xorg/xwayland.nix +++ b/pkgs/servers/x11/xorg/xwayland.nix @@ -1,16 +1,18 @@ -{ stdenv, wayland, wayland-protocols, xorgserver, xkbcomp, xkeyboard_config, epoxy, libxslt, libunwind, makeWrapper }: +{ stdenv, wayland, wayland-protocols, xorgserver, xkbcomp, xkeyboard_config, epoxy, libxslt, libunwind, makeWrapper, egl-wayland }: with stdenv.lib; xorgserver.overrideAttrs (oldAttrs: { name = "xwayland-${xorgserver.version}"; + buildInputs = oldAttrs.buildInputs ++ [ egl-wayland ]; propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [wayland wayland-protocols epoxy libxslt makeWrapper libunwind]; configureFlags = [ "--disable-docs" "--disable-devel-docs" "--enable-xwayland" + "--enable-xwayland-eglstream" "--disable-xorg" "--disable-xvfb" "--disable-xnest" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ec4c15f6069..0f49075972e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11030,6 +11030,8 @@ in inherit (darwin.apple_sdk.frameworks) Accelerate CoreGraphics CoreVideo; }; + egl-wayland = callPackage ../development/libraries/egl-wayland {}; + elastix = callPackage ../development/libraries/science/biology/elastix { }; enchant1 = callPackage ../development/libraries/enchant/1.x.nix { };