How to install emacs package with built-in dependency instead of elpa package?

I use Nix to manage Emacs packages, and I found that the package eglot have an denpendency on xref,
so Nix will install the elpa version of xref which will hides the built-in xref in load-path.

When I execute xref-find-definition and then execute the command xref-go-back, I will get the error:

command-execute: Autoloading file /nix/store/ss33d2r5f7vcxca19jdnnp2q8rlapcm2-emacs-packages-deps/share/emacs/site-lisp/elpa/xref-1.3.2/xref.elc failed to define function xref-go-back

Execute M-x, list-load-path-shadows, will get the result as below:

/nix/store/ss33d2r5f7vcxca19jdnnp2q8rlapcm2-emacs-packages-deps/share/emacs/site-lisp/elpa/xref-1.3.2/xref hides /nix/store/k0xw4azi63qpp5wj3vicndkyny6c806f-emacs-git-20211204.0/share/emacs/29.0.50/lisp/progmodes/xref

This issue can be reproduce with emacs -q

And I tried to remove eglot from Nix , the built-in xref will works as expected.

Emacs: Emacs 29.0.50, EmacsGit installed with nix-community/emacs-overlay
Platform: macOS Monterey, with Nix 2.4

My nix-config and emacs-config