Difficulties regarding executing the xserver in a login manager

Hey! I’m trying to package sonic-login-manager for nixOS, and I’ve had some success, but am really struggling. Right now, it’s failing due to being unable to find any modules. Here’s the relevant parts of the systemd log:

Jun 04 08:52:18 nixos soniclogin[1528]: [X11 USER HELPER] Running server: /nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X -nolisten tcp -background none -seat seat0 -noreset -keeptty -novtswitch -verbose 3 -auth /run/user/991/xauth_EYyJRB -displayfd 13 vt1
...
Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X]         (++) from command line, (!!) notice, (II) informational,

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X]         (WW) warning, (EE) error, (NI) not implemented, (??) unknown.

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) The directory "/nix/store/rzv9xpwnmqghy88jy5fsg79ninbbcabc-font-util-1.4.2/share/fonts/X11/misc" does not exist.

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) The directory "/nix/store/rzv9xpwnmqghy88jy5fsg79ninbbcabc-font-util-1.4.2/share/fonts/X11/TTF" does not exist.

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) The directory "/nix/store/rzv9xpwnmqghy88jy5fsg79ninbbcabc-font-util-1.4.2/share/fonts/X11/OTF" does not exist.

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) The directory "/nix/store/rzv9xpwnmqghy88jy5fsg79ninbbcabc-font-util-1.4.2/share/fonts/X11/Type1" does not exist.

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) The directory "/nix/store/rzv9xpwnmqghy88jy5fsg79ninbbcabc-font-util-1.4.2/share/fonts/X11/100dpi" does not exist.

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) The directory "/nix/store/rzv9xpwnmqghy88jy5fsg79ninbbcabc-font-util-1.4.2/share/fonts/X11/75dpi" does not exist.

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) Warning, couldn't open module nouveau

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE) Failed to load module "nouveau" (module does not exist, 0)

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) Warning, couldn't open module nv

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE) Failed to load module "nv" (module does not exist, 0)

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) Warning, couldn't open module fbdev

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE) Failed to load module "fbdev" (module does not exist, 0)

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) Warning, couldn't open module vesa

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE) Failed to load module "vesa" (module does not exist, 0)

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE) modeset(0): Failed to create pixmap

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE)

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] Fatal server error:

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE) failed to create screen resources(EE)

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE)

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE) Please also check the log file at "/var/lib/soniclogin/.local/share/xorg/Xorg.0.log" for additional information.

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE)

Jun 04 08:52:19 nixos soniclogin[1528]: [X11 USER HELPER] [/nix/store/7kp2yc8wf3riniyjifcwqsxsh1r2awqy-xorg-server-21.1.22/bin/X] (EE) Server terminated with error (1). Closing log file.

I feel like the reason this is happening is it’s launching without any configuration at all. Can somebody help me out? at the very least, I can create a patch file that gives the $ xorg -options… string a path to the configuration file I’m supposed to use

packaging source here
relevant source code for sonic-login-manager and xorg launcher + options here
sonic-login-manager source code here

I’ve found out that setting
services.xserver.exportConfiguration = true;
will write /etc/X11/xorg.conf, but doing that and then hardcoding a path to it feels wrong

Looking through the source code, I’m finding a TON of references to hardcoded FHS paths. What’s the proper nix way to handle this? Can someone help me out?