XDM cannot find the correct path for X

I am running Nix in container, which means it is not NixOS.

The function I want to do is XDMCP service. So I installed xlibs.xorgserver and xlibs.xdm. Then run xdm manually. The log shows

xdm error (pid 769): server /nix/store/ka806yqpm3kiikhjn64ivw8aypzjxkx1-xdm-1.1.12/bin/X cannot be executed
xdm error (pid 767): Server for display :0 terminated unexpectedly: 1

And I do have /root/.nix-profile/bin/X -> /nix/store/7rc2d0l1s70lhvl8nwaas672bn45yq1l-xorg-server-1.20.4/bin/X.

Apparently, xdm tries to start X from where it sits.

So what did I do wrong?