SOLVED Update rendered my graphical system unusable: startx Xorg issue: `(WW) Falling back to old probe method for modesetting`, `(EE) unw_get_proc_name failed: no unwind info found [-10]`

Hello, in my Lenovo Optimus laptop (Intel iGPU and Nvidia GPU) I’ve updated my nixpkgs flake input rev from 551c27677d66d635004f44784d10643edfaec6d to 23e89b7da85c3640bbc2173fe04f4bd114342367 and nixos-rebuild succesfully (after many interventions). Now, when I try to startx to start X, I get many errors (looks like it’s not using intel drivers for my intel iGPU and falling back to modesetting): (EE) unw_get_proc_name failed: no unwind info found [-10]. I’d be very thankful to anyone who have any ideas fixing it since it’s in a unusable state for me basically.

...
[  5746.419] (II) LoadModule: "intel"
[  5746.419] (II) Loading /nix/store/4zpgpfhhqf1sxxlizvi9gp8rf85pqr8w-xf86-video-intel-2021-01-15/lib/xorg/modules/drivers/intel_drv.so
[  5746.420] (II) Module intel: vendor="X.Org Foundation"
[  5746.420] 	compiled for 1.21.1.14, module version = 2.99.917
[  5746.420] 	Module class: X.Org Video Driver
[  5746.420] 	ABI class: X.Org Video Driver, version 25.2
[  5746.420] (II) LoadModule: "modesetting"
[  5746.421] (II) Loading /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/drivers/modesetting_drv.so
[  5746.421] (II) Module modesetting: vendor="X.Org Foundation"
[  5746.421] 	compiled for 1.21.1.14, module version = 1.21.1
[  5746.421] 	Module class: X.Org Video Driver
[  5746.422] 	ABI class: X.Org Video Driver, version 25.2
[  5746.422] (II) intel: Driver for Intel(R) Integrated Graphics Chipsets:
	i810, i810-dc100, i810e, i815, i830M, 845G, 854, 852GM/855GM, 865G,
	915G, E7221 (i915), 915GM, 945G, 945GM, 945GME, Pineview GM,
	Pineview G, 965G, G35, 965Q, 946GZ, 965GM, 965GME/GLE, G33, Q35, Q33,
	GM45, 4 Series, G45/G43, Q45/Q43, G41, B43
[  5746.424] (II) intel: Driver for Intel(R) HD Graphics
[  5746.424] (II) intel: Driver for Intel(R) Iris(TM) Graphics
[  5746.424] (II) intel: Driver for Intel(R) Iris(TM) Pro Graphics
[  5746.424] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[  5746.424] xf86EnableIO: failed to enable I/O ports 0000-03ff (Operation not permitted)
[  5746.424] (II) intel(0): Using Kernel Mode Setting driver: i915, version 1.6.0 20201103
[  5746.425] (WW) Falling back to old probe method for modesetting
[  5746.425] (II) modeset(G0): using drv /dev/dri/card0
...
[  5746.479] (II) Initializing extension GLX
[  5746.571] (EE) 
[  5746.572] (EE) Backtrace:
[  5746.573] (EE) 0: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (OsSigHandler+0x33) [0x5c2c33]
[  5746.575] (EE) unw_get_proc_name failed: no unwind info found [-10]
[  5746.575] (EE) 1: /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6 (?+0x0) [0x7f3417958620]
[  5746.577] (EE) 2: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/extensions/libglx.so (glxConvertConfigs+0x12) [0x7f341769ab92]
[  5746.579] (EE) 3: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/extensions/libglx.so (__glXDRIscreenProbe+0x2e8) [0x7f34176a2e98]
[  5746.580] (EE) 4: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/extensions/libglx.so (xorgGlxServerInit+0xb7) [0x7f34176992b7]
[  5746.581] (EE) 5: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (_CallCallbacks+0x34) [0x44c474]
[  5746.581] (EE) 6: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (GlxExtensionInit+0x15f) [0x57e9bf]
[  5746.582] (EE) 7: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (InitExtensions+0x89) [0x4bbce9]
[  5746.583] (EE) 8: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (dix_main+0x1ac) [0x44ad8c]
[  5746.585] (EE) 9: /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6 (__libc_start_call_main+0x7e) [0x7f341794227e]
[  5746.587] (EE) 10: /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6 (__libc_start_main+0x89) [0x7f3417942339]
[  5746.587] (EE) 11: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (_start+0x25) [0x433175]
[  5746.587] (EE) 
[  5746.587] (EE) Segmentation fault at address 0x0
[  5746.587] (EE) 
Fatal server error:
[  5746.587] (EE) Caught signal 11 (Segmentation fault). Server aborting
[  5746.587] (EE) 
[  5746.587] (EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
[  5746.587] (EE) Please also check the log file at "/home/marmar/.local/share/xorg/Xorg.0.log" for additional information.
[  5746.588] (EE) 
[  5746.620] (EE) Server terminated with error (1).

Logs/Backtrace

Xorg.0.log:

[  5746.296] 
X.Org X Server 1.21.1.14
X Protocol Version 11, Revision 0
[  5746.300] Current Operating System: Linux marmar-nixos 6.6.62 #1-NixOS SMP PREEMPT_DYNAMIC Sun Nov 17 14:08:59 UTC 2024 x86_64
[  5746.300] Kernel command line: initrd=\EFI\nixos\1sab2inycimns2xbd505nwmxy0fvb2v1-initrd-linux-6.6.62-initrd.efi init=/nix/store/a8dc07b23n7lad45rcr0s93j2vzi422w-nixos-system-marmar-nixos-25.05.20241119.23e89b7/init rfkill.default_state=1 resume_offset=[2185012] loglevel=4 nvidia-drm.modeset=1 nvidia-drm.fbdev=1
[  5746.304]  
[  5746.306] Current version of pixman: 0.43.4
[  5746.308] 	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
[  5746.308] Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[  5746.314] (==) Log file: "/home/marmar/.local/share/xorg/Xorg.0.log", Time: Sat Nov 23 15:52:51 2024
[  5746.316] (++) Using config file: "/nix/store/i723dsa6c43nin4k3702n0wqyni9yd73-xserver.conf"
[  5746.318] (==) Using config directory: "/etc/X11/xorg.conf.d"
[  5746.319] (==) Using system config directory "/nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/share/X11/xorg.conf.d"
[  5746.321] (==) ServerLayout "Layout[all]"
[  5746.324] (**) |-->Screen "Screen-intel[0]" (0)
[  5746.325] (**) |   |-->Monitor "<default monitor>"
[  5746.327] (**) |   |-->Device "Device-intel[0]"
[  5746.329] (==) No monitor specified for screen "Screen-intel[0]".
	Using a default monitor configuration.
[  5746.330] (**) |-->Screen "Screen-modesetting[0]" (1)
[  5746.331] (**) |   |-->Monitor "<default monitor>"
[  5746.333] (**) |   |-->Device "Device-modesetting[0]"
[  5746.336] (==) No monitor specified for screen "Screen-modesetting[0]".
	Using a default monitor configuration.
[  5746.336] (**) Option "DontZap" "on"
[  5746.338] (**) Option "AllowMouseOpenFail" "on"
[  5746.340] (**) Allowing byte-swapped clients
[  5746.341] (==) Automatically adding devices
[  5746.342] (==) Automatically enabling devices
[  5746.344] (==) Automatically adding GPU devices
[  5746.345] (==) Automatically binding GPU devices
[  5746.348] (==) Max clients allowed: 256, resource mask: 0x1fffff
[  5746.364] (**) FontPath set to:
	/nix/store/vr6ycm45cppkjp6an07y1r79fpjxipws-font-cursor-misc-1.0.4/lib/X11/fonts/misc,
	/nix/store/bw6mdh23wckwd78sjxsiyl5vlimjs63k-font-misc-misc-1.1.3/lib/X11/fonts/misc,
	/nix/store/xn9d7w44krbnx9gkk5kvb4lidzwzf6cn-unifont-16.0.01/share/fonts,
	/nix/store/87gk2jxsd5l6lcl7n6bk66db3a9hrggf-font-adobe-100dpi-1.0.4/lib/X11/fonts/100dpi,
	/nix/store/yc1by5p1acgs9xwyqpxmljxf7g29chm1-font-adobe-75dpi-1.0.4/lib/X11/fonts/75dpi,
	/nix/store/q1in236cvyrk4skcwp7hr6nykwslqff5-X11-fonts/share/X11/fonts
[  5746.367] (**) ModulePath set to "/nix/store/4zpgpfhhqf1sxxlizvi9gp8rf85pqr8w-xf86-video-intel-2021-01-15/lib/xorg/modules,/nix/store/yv0ygl8ryxphcdzw9hyfbfhnxa81bw59-nvidia-x11-560.35.03-6.6.62-bin/lib/xorg/modules,/nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules,/nix/store/f3bl0b1d9p5s801nzfd841lz4vvs8d6c-xf86-input-evdev-2.11.0/lib/xorg/modules,/nix/store/q64rw2c0sm2gr69s9f0xmrip5s8cyp75-xf86-input-libinput-1.5.0/lib/xorg/modules"
[  5746.370] (II) The server relies on udev to provide the list of input devices.
	If no devices become available, reconfigure udev or disable AutoAddDevices.
[  5746.373] (II) Loader magic: 0x64ee40
[  5746.374] (II) Module ABI versions:
[  5746.377] 	X.Org ANSI C Emulation: 0.4
[  5746.380] 	X.Org Video Driver: 25.2
[  5746.383] 	X.Org XInput driver : 24.4
[  5746.385] 	X.Org Server Extension : 10.0
[  5746.390] (++) using VT number 5

[  5746.395] (II) systemd-logind: took control of session /org/freedesktop/login1/session/_36
[  5746.398] (II) xfree86: Adding drm device (/dev/dri/card1)
[  5746.398] (II) Platform probe for /sys/devices/pci0000:00/0000:00:02.0/drm/card1
[  5746.400] (II) systemd-logind: got fd for /dev/dri/card1 226:1 fd 13 paused 0
[  5746.402] (II) xfree86: Adding drm device (/dev/dri/card0)
[  5746.402] (II) Platform probe for /sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/drm/card0
[  5746.404] (II) systemd-logind: got fd for /dev/dri/card0 226:0 fd 14 paused 0
[  5746.413] (--) PCI:*(0@0:2:0) 8086:5916:17aa:38e2 rev 2, Mem @ 0xa2000000/16777216, 0xb0000000/268435456, I/O @ 0x00005000/64, BIOS @ 0x????????/131072
[  5746.413] (--) PCI: (1@0:0:0) 10de:134d:17aa:38e2 rev 162, Mem @ 0xa3000000/16777216, 0x90000000/268435456, 0xa0000000/33554432, I/O @ 0x00004000/128
[  5746.414] (II) Open ACPI successful (/var/run/acpid.socket)
[  5746.414] (II) "glx" will be loaded by default.
[  5746.414] (II) LoadModule: "glx"
[  5746.415] (II) Loading /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/extensions/libglx.so
[  5746.418] (II) Module glx: vendor="X.Org Foundation"
[  5746.419] 	compiled for 1.21.1.14, module version = 1.0.0
[  5746.419] 	ABI class: X.Org Server Extension, version 10.0
[  5746.419] (II) LoadModule: "intel"
[  5746.419] (II) Loading /nix/store/4zpgpfhhqf1sxxlizvi9gp8rf85pqr8w-xf86-video-intel-2021-01-15/lib/xorg/modules/drivers/intel_drv.so
[  5746.420] (II) Module intel: vendor="X.Org Foundation"
[  5746.420] 	compiled for 1.21.1.14, module version = 2.99.917
[  5746.420] 	Module class: X.Org Video Driver
[  5746.420] 	ABI class: X.Org Video Driver, version 25.2
[  5746.420] (II) LoadModule: "modesetting"
[  5746.421] (II) Loading /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/drivers/modesetting_drv.so
[  5746.421] (II) Module modesetting: vendor="X.Org Foundation"
[  5746.421] 	compiled for 1.21.1.14, module version = 1.21.1
[  5746.421] 	Module class: X.Org Video Driver
[  5746.422] 	ABI class: X.Org Video Driver, version 25.2
[  5746.422] (II) intel: Driver for Intel(R) Integrated Graphics Chipsets:
	i810, i810-dc100, i810e, i815, i830M, 845G, 854, 852GM/855GM, 865G,
	915G, E7221 (i915), 915GM, 945G, 945GM, 945GME, Pineview GM,
	Pineview G, 965G, G35, 965Q, 946GZ, 965GM, 965GME/GLE, G33, Q35, Q33,
	GM45, 4 Series, G45/G43, Q45/Q43, G41, B43
[  5746.424] (II) intel: Driver for Intel(R) HD Graphics
[  5746.424] (II) intel: Driver for Intel(R) Iris(TM) Graphics
[  5746.424] (II) intel: Driver for Intel(R) Iris(TM) Pro Graphics
[  5746.424] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[  5746.424] xf86EnableIO: failed to enable I/O ports 0000-03ff (Operation not permitted)
[  5746.424] (II) intel(0): Using Kernel Mode Setting driver: i915, version 1.6.0 20201103
[  5746.425] (WW) Falling back to old probe method for modesetting
[  5746.425] (II) modeset(G0): using drv /dev/dri/card0
[  5746.425] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
[  5746.426] (--) intel(0): Integrated Graphics Chipset: Intel(R) HD Graphics 620
[  5746.426] (--) intel(0): CPU: x86-64, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2; using a maximum of 2 threads
[  5746.426] (II) intel(0): Creating default Display subsection in Screen section
	"Screen-intel[0]" for depth/fbbpp 24/32
[  5746.426] (==) intel(0): Depth 24, (--) framebuffer bpp 32
[  5746.426] (==) intel(0): RGB weight 888
[  5746.426] (==) intel(0): Default visual is TrueColor
[  5746.429] (II) intel(0): Output eDP1 has no monitor section
[  5746.455] (**) intel(0): Found backlight control interface intel_backlight (type 'raw') for output eDP1
[  5746.456] (II) intel(0): Enabled output eDP1
[  5746.456] (II) intel(0): Output HDMI1 has no monitor section
[  5746.456] (II) intel(0): Enabled output HDMI1
[  5746.457] (II) intel(0): Output DP1 has no monitor section
[  5746.457] (II) intel(0): Enabled output DP1
[  5746.457] (II) intel(0): Output HDMI2 has no monitor section
[  5746.458] (II) intel(0): Enabled output HDMI2
[  5746.458] (--) intel(0): Using a maximum size of 256x256 for hardware cursors
[  5746.458] (II) intel(0): Output VIRTUAL1 has no monitor section
[  5746.458] (II) intel(0): Enabled output VIRTUAL1
[  5746.459] (--) intel(0): Output eDP1 using initial mode 1920x1080 on pipe 0
[  5746.459] (==) intel(0): TearFree enabled
[  5746.459] (==) intel(0): Using gamma correction (1.0, 1.0, 1.0)
[  5746.459] (==) intel(0): DPI set to (96, 96)
[  5746.459] (II) Loading sub module "dri3"
[  5746.459] (II) LoadModule: "dri3"
[  5746.459] (II) Module "dri3" already built-in
[  5746.459] (II) Loading sub module "dri2"
[  5746.459] (II) LoadModule: "dri2"
[  5746.459] (II) Module "dri2" already built-in
[  5746.459] (II) Loading sub module "present"
[  5746.459] (II) LoadModule: "present"
[  5746.459] (II) Module "present" already built-in
[  5746.460] (II) modeset(G0): Using 24bpp hw front buffer with 32bpp shadow
[  5746.461] (==) modeset(G0): Depth 24, (==) framebuffer bpp 32
[  5746.461] (==) modeset(G0): RGB weight 888
[  5746.461] (==) modeset(G0): Default visual is TrueColor
[  5746.461] (**) modeset(G0): Cannot use glamor with 24bpp packed fb
[  5746.461] (II) modeset(G0): ShadowFB: preferred YES, enabled FORCE
[  5746.461] (II) modeset(G0): Double-buffered shadow updates: off
[  5746.461] (==) modeset(G0): Using gamma correction (1.0, 1.0, 1.0)
[  5746.461] (==) modeset(G0): DPI set to (96, 96)
[  5746.461] (II) Loading sub module "fb"
[  5746.461] (II) LoadModule: "fb"
[  5746.461] (II) Module "fb" already built-in
[  5746.461] (II) Loading sub module "shadow"
[  5746.461] (II) LoadModule: "shadow"
[  5746.462] (II) Loading /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/libshadow.so
[  5746.463] (II) Module shadow: vendor="X.Org Foundation"
[  5746.463] 	compiled for 1.21.1.14, module version = 1.1.0
[  5746.463] 	ABI class: X.Org ANSI C Emulation, version 0.4
[  5746.464] (II) intel(0): SNA initialized with Kabylake (gen9) backend
[  5746.464] (==) intel(0): Backing store enabled
[  5746.464] (==) intel(0): Silken mouse enabled
[  5746.464] (II) intel(0): HW Cursor enabled
[  5746.465] (==) intel(0): DPMS enabled
[  5746.465] (==) intel(0): Display hotplug detection enabled
[  5746.465] (II) intel(0): [DRI2] Setup complete
[  5746.465] (II) intel(0): [DRI2]   DRI driver: iris
[  5746.465] (II) intel(0): [DRI2]   VDPAU driver: va_gl
[  5746.466] (II) intel(0): direct rendering: DRI2 DRI3 enabled
[  5746.466] (II) intel(0): hardware support for Present enabled
[  5746.466] (==) modeset(G0): Backing store enabled
[  5746.466] (==) modeset(G0): Silken mouse enabled
[  5746.466] (II) modeset(G0): Initializing kms color map for depth 24, 8 bpc.
[  5746.467] (==) modeset(G0): DPMS enabled
[  5746.467] (II) Initializing extension Generic Event Extension
[  5746.467] (II) Initializing extension SHAPE
[  5746.468] (II) Initializing extension MIT-SHM
[  5746.468] (II) Initializing extension XInputExtension
[  5746.469] (II) Initializing extension XTEST
[  5746.469] (II) Initializing extension BIG-REQUESTS
[  5746.470] (II) Initializing extension SYNC
[  5746.471] (II) Initializing extension XKEYBOARD
[  5746.471] (II) Initializing extension XC-MISC
[  5746.472] (II) Initializing extension SECURITY
[  5746.472] (II) Initializing extension XFIXES
[  5746.473] (II) Initializing extension RENDER
[  5746.473] (II) Initializing extension RANDR
[  5746.474] (II) Initializing extension COMPOSITE
[  5746.474] (II) Initializing extension DAMAGE
[  5746.475] (II) Initializing extension MIT-SCREEN-SAVER
[  5746.475] (II) Initializing extension DOUBLE-BUFFER
[  5746.476] (II) Initializing extension RECORD
[  5746.476] (II) Initializing extension DPMS
[  5746.477] (II) Initializing extension Present
[  5746.477] (II) Initializing extension DRI3
[  5746.478] (II) Initializing extension X-Resource
[  5746.478] (II) Initializing extension XVideo
[  5746.479] (II) Initializing extension XVideo-MotionCompensation
[  5746.479] (II) Initializing extension GLX
[  5746.571] (EE) 
[  5746.572] (EE) Backtrace:
[  5746.573] (EE) 0: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (OsSigHandler+0x33) [0x5c2c33]
[  5746.575] (EE) unw_get_proc_name failed: no unwind info found [-10]
[  5746.575] (EE) 1: /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6 (?+0x0) [0x7f3417958620]
[  5746.577] (EE) 2: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/extensions/libglx.so (glxConvertConfigs+0x12) [0x7f341769ab92]
[  5746.579] (EE) 3: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/extensions/libglx.so (__glXDRIscreenProbe+0x2e8) [0x7f34176a2e98]
[  5746.580] (EE) 4: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/lib/xorg/modules/extensions/libglx.so (xorgGlxServerInit+0xb7) [0x7f34176992b7]
[  5746.581] (EE) 5: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (_CallCallbacks+0x34) [0x44c474]
[  5746.581] (EE) 6: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (GlxExtensionInit+0x15f) [0x57e9bf]
[  5746.582] (EE) 7: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (InitExtensions+0x89) [0x4bbce9]
[  5746.583] (EE) 8: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (dix_main+0x1ac) [0x44ad8c]
[  5746.585] (EE) 9: /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6 (__libc_start_call_main+0x7e) [0x7f341794227e]
[  5746.587] (EE) 10: /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6 (__libc_start_main+0x89) [0x7f3417942339]
[  5746.587] (EE) 11: /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X (_start+0x25) [0x433175]
[  5746.587] (EE) 
[  5746.587] (EE) Segmentation fault at address 0x0
[  5746.587] (EE) 
Fatal server error:
[  5746.587] (EE) Caught signal 11 (Segmentation fault). Server aborting
[  5746.587] (EE) 
[  5746.587] (EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
[  5746.587] (EE) Please also check the log file at "/home/marmar/.local/share/xorg/Xorg.0.log" for additional information.
[  5746.588] (EE) 
[  5746.620] (EE) Server terminated with error (1). Closing log file.

uname -r

6.6.62

lspci | grep VGA|3D

00:02.0 VGA compatible controller: Intel Corporation HD Graphics 620 (rev 02)
01:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 940MX] (rev a2)

lshw -c display

*-display
       product: i915drmfb
       physical id: 2
       bus info: pci@0000:00:02.0
       logical name: /dev/fb0
       version: 02
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm bus_master cap_list rom fb
       configuration: depth=32 driver=i915 latency=0 resolution=1920,1080
       resources: irq:129 memory:a2000000-a2ffffff memory:b0000000-bfffffff ioport:5000(size=64) memory:c0000-dffff
  *-display
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a2
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list rom
       configuration: driver=nvidia latency=0
       resources: irq:136 memory:a3000000-a3ffffff memory:90000000-9fffffff memory:a0000000-a1ffffff ioport:4000(size=128)

nvidia-smi

Sat Nov 23 16:20:42 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.35.03              Driver Version: 560.35.03      CUDA Version: 12.6     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce 940MX           Off |   00000000:01:00.0 Off |                  N/A |
| N/A   49C    P8             N/A /  200W |       0MiB /   2048MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

My NixOS relevant files

flake.nix

{
  nixConfig = {
    extra-substituters = [
      "https://nix-community.cachix.org"
    ];

    extra-trusted-public-keys = [
      "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
    ];
  };

  inputs = {
    nixpkgs = {
      type = "github";
      owner = "nixos";
      repo = "nixpkgs";
      rev = "23e89b7da85c3640bbc2173fe04f4bd114342367";
    };

    nixpkgs-update = {
      type = "github";
      owner = "nixos";
      repo = "nixpkgs";
      ref = "nixos-unstable";
      rev = "23e89b7da85c3640bbc2173fe04f4bd114342367";
    };

    home-manager = {
      type = "github";
      owner = "nix-community";
      repo = "home-manager";
    };

    xmonad = {
      type = "github";
      owner = "xmonad";
      repo = "xmonad";
      ref = "master";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    xmonad-contrib = {
      type = "github";
      owner = "xmonad";
      repo = "xmonad-contrib";
      ref = "master";
      inputs.nixpkgs.follows = "nixpkgs";
    };

  outputs = (inputs@{
    self
    , nixpkgs
    , nixpkgs-update
    , home-manager
    , xmonad
    , xmonad-contrib
    , ...
  }:
    let
      inherit (nixpkgs.lib) filterAttrs;
      inherit (builtins) mapAttrs elem;
      inherit (self) outputs;

      lib = import nixpkgs.lib;

      supportedLocalSystems = [
        "x86_64-linux"
        "aarch64-linux"
      ];
      forAllLocalSystems = nixpkgs.lib.genAttrs supportedLocalSystems;
      marmarLocalSystem = "x86_64-linux";

      homeManagerModules = import ./modules/home-manager;

      legacyPackagesUpdate = forAllLocalSystems (localSystem:
        import nixpkgs-update {
          inherit localSystem;

          overlays = (builtins.attrValues outputs.overlays);
          config.allowUnfree = true;
        }
      );
    in {
      inherit
        forAllLocalSystems
        legacyPackagesUpdate
        marmarLocalSystem
        homeManagerModules
      ;

      nixosConfigurations = {
        marmar = nixpkgs.lib.nixosSystem {
          specialArgs = {
            inherit
              inputs
              outputs
            ;

            pkgs-update = legacyPackagesUpdate."${marmarLocalSystem}";
          };

          modules = [
            ./host/marmar
          ];
        };
      };
    }
  );
}

x.nix

{ config
, lib
, pkgs
, ...
}:

{
  services = {
    xserver = {
      enable = true;

      # Make sure /etc/X11/xkb is populated.
      # https://github.com/NixOS/nixpkgs/issues/19629#issuecomment-368051434
      exportConfiguration = true;

      desktopManager = {
        # https://nixos.org/manual/nixos/unstable/release-notes.html#sec-release-22.05
        runXdgAutostartIfNone = true;
      };

      displayManager.startx.enable = true;
    };
  };

  home-manager.users.marmar = {
    xresources = {
      properties = {
        "Xcursor.size" = "32";
        "Xcursor.theme" = "oreo_spark_orange_cursors";
        "Xft.antialias" = "true";
        "Xft.autohint" = "false";
        "Xft.dpi" = "96";
        "Xft.hinting" = "true";
        "Xft.hintstyle" = "hintslight";
        "Xft.lcdfilter" = "lcddefault";
        "Xft.rgba" = "rgb";
      };
    };

    home.packages = with pkgs; [
      libva-utils
      xbrightness
      xclip
      xdo
      xdotool
      xorg.xcompmgr
      xorg.xfontsel
      xorg.xkill
      xorg.xrandr
      xsettingsd
      xwallpaper
      arandr
      lxrandr
    ];
  };
}

prime.nix

{ config
, lib
, pkgs
, ...
}:

# https://nixos.wiki/wiki/Nvidia#Optimus

let
  # https://nixos.wiki/wiki/Nvidia#offload_mode
  nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
    export __NV_PRIME_RENDER_OFFLOAD=1
    export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
    export __GLX_VENDOR_LIBRARY_NAME=nvidia
    export __VK_LAYER_NV_optimus=NVIDIA_only
    exec "$@"
    '';
in
{
  environment.systemPackages = with pkgs; [
    nvidia-offload
    glxinfo
  ];

  services.xserver.videoDrivers = [
    "intel"
    "nvidia"
  ];

  hardware = {
    nvidia = {
      nvidiaPersistenced = false;

      prime = {
        offload.enable = true;

        # https://discourse.nixos.org/t/struggling-with-nvidia-prime/13794/4
        intelBusId = "0@0:2:0";
        nvidiaBusId = "1@1:0:0";
      };

      # You must configure `hardware.nvidia.open` on NVIDIA driver versions >= 560.
      # It is suggested to use the open source kernel modules on Turing or later GPUs (RTX series, GTX 16xx), and the closed source modules otherwise.
      open = false;
    };
  };
}

X configuration files

~/.xinitrc

let-env userresources = $"$(env.HOME)/.Xresources"
let-env usermodmap = $"$(env.HOME)/.Xmodmap"
let-env MANPATH = $"(manpath)"

dbus-daemon --session --address="unix:path=/run/user/(id --user)/bus"
systemctl --user import-environment DISPLAY XAUTHORITY
systemctl --user start graphical-session.target

# https://wiki.archlinux.org/title/Cursor_themes#X_resources
xrdb userresources

xbindkeys; exec xmonad

~/.Xresources

Xcursor.size: 32
Xcursor.theme: oreo_spark_orange_cursors
Xft.antialias: true
Xft.autohint: false
Xft.dpi: 96
Xft.hinting: true
Xft.hintstyle: hintslight
Xft.lcdfilter: lcddefault
Xft.rgba: rgb

~/.Xmodmap

! Esc
keycode 9 = Multi_key
add mod5 = Multi_key
! F1
keycode 121 = XF86AudioMute NoSymbol XF86AudioMute
! F2
keycode 122 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume
! F3
keycode 123 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume
! F4
keycode 198 = XF86AudioMicMute NoSymbol XF86AudioMicMute
! F7
keycode 255 = XF86RFKill NoSymbol XF86RFKill
! F8
keycode 220 = XF86WebCam NoSymbol XF86WebCam
! F9
! F10
keycode  33 = p P p P thorn THORN thorn
! F11
keycode 232 = XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown
! F12
keycode 233 = XF86MonBrightnessUp NoSymbol XF86MonBrightnessUp

/etc/X11/xinit/xserverrc

#!/nix/store/0irlcqx2n3qm6b1pc9rsd2i8qpvcccaj-bash-5.2p37/bin/bash
exec /nix/store/cwa9ihrzv9zcg6rci26g5kxj7lgm3110-xorg-server-21.1.14/bin/X -config /nix/store/i723dsa6c43nin4k3702n0wqyni9yd73-xserver.conf -xkbdir /nix/store/r0y3gdr05wccnz1n34a7262imck6576k-xkeyboard-config-2.43/etc/X11/xkb :0 vt7 -verbose 3 -nolisten tcp -terminate "$@"

SOLUTION by @k900:0upti.me @k900

In prime.nix, change

services.xserver.videoDrivers = [
    "intel"
    "nvidia"
];

TO

services.xserver.videoDrivers = [
    "nvidia"
];

OR

services.xserver.videoDrivers = [
    "modesetting"
    "nvidia"
];

Quotes

Remove intel from videoDrivers

I swear I will one day get sufficiently upset and delete all the DDXes from nixpkgs forever

@k900:0upti.me, You're invited to talk on Matrix

Just don’t use DDXes

They’re the worst and we should have stopped shipping them a long time ago

I’m kind of surprised upstream hasn’t ripped the whole thing out yet

But I guess Nvidia

Nvidia being the second worst thing after DDXes

@k900:0upti.me

Hm I see, Device Dependent X drivers… If you could also please look at this new Xorg.0.log, can you say if it is using the Intel iGPU driver or falling back to modesetting? https://0x0.st/X5xi.log

@marmarsea:matrix.org

Oh wait, now nvidia is actually running X. What I used to do is have intel iGPU run X and nvidia-offload specific programs like Davinci Resolve for hardware acceleration

@marmarsea:matrix.org

Modesetting is the one you want to be using

@k900:0upti.me

I see, seems to be working as expected after testing for a while. It auto runs with nvidia software with hardware acceleration enabled and the others with intel iGPU. Thank you so much. I will write the solution and your comments on the discourse thread and credit you. Thank you very much!

@marmarsea@matrix.org