@@ -126,11 +126,21 @@ in
126126 wayland = mkOption {
127127 default = true;
128128 description = ''
129− Allow GDM run on Wayland instead of Xserver
129+ Allow GDM to run on Wayland instead of Xserver.
130+ Note to enable Wayland with Nvidia you need to
131+ enable the <option>nvidiaWayland</option>.
130132 '';
131133 type = types.bool;
132134 };
133135
136+ nvidiaWayland = mkOption {
137+ default = false;
138+ description = ''
139+ Whether to allow wayland to be used with the proprietary
140+ NVidia graphics driver.
141+ '';
142+ };
143+
134144 autoSuspend = mkOption {
135145 default = true;
136146 description = ''
@@ -237,6 +247,19 @@ in
237247
238248 services.dbus.packages = [ gdm ];
239249
250+ # We duplicate upstream's udev rules manually to make wayland with nvidia configurable
251+ services.udev.extraRules = ''
252+ # disable Wayland on Cirrus chipsets
253+ ATTR{vendor}=="0x1013", ATTR{device}=="0x00b8", ATTR{subsystem_vendor}=="0x1af4", ATTR{subsystem_device}=="0x1100", RUN+="${gdm}/libexec/gdm-disable-wayland"
254+ # disable Wayland on Hi1710 chipsets
255+ ATTR{vendor}=="0x19e5", ATTR{device}=="0x1711", RUN+="${gdm}/libexec/gdm-disable-wayland"
256+ ${optionalString (!cfg.gdm.nvidiaWayland) ''
257+ DRIVER=="nvidia", RUN+="${gdm}/libexec/gdm-disable-wayland"
258+ ''}
259+ # disable Wayland when modesetting is disabled
260+ IMPORT{cmdline}="nomodeset", RUN+="${gdm}/libexec/gdm-disable-wayland"
261+ '';
262+
240263 systemd.user.services.dbus.wantedBy = [ "default.target" ];
241264
242265 programs.dconf.profiles.gdm =