Infinite recursion encountered by `fileSystem` depend on `home-manager`

I need to bind mount (instead of soft link) .zshrc file (generated by home-manager) into /home/chn/.zshrc, but it will encounter infinite recursion.

fileSystems."/home/chn/.zshrc" =
{
  device = "${config.home-manager.users.chn.home.file.".zshrc".source}";
  options = [ "bind" ];
};

Does anyone knows how to fix or workaround it?

I workaround it by setting systemd.mounts instead of fileSystems.

Also home.file creates a symlink, I don’t see the benefit of creating that AND a bind mount.

I tried to create a bind mount and disable the symlink. Disabling the symlink is easy, so I did not mention it.

I want to use bind mounts instead of symlinks on the cluster with shared home directories between several nodes. With bind mounts, ~/.zshrc on each node will be mounted from the nix store of the separate node and could have different content across nodes. With symlinks, however, ~/.zshrc will have the same content across nodes, pointing to the nix store of a random node (whose home-manager service was started latest), making other nodes fail to read its content.

I tried to set users.users.chn.home and home-manager.users.chn.home.homeDirectory manually, but the infinite recursion still exists. I think the issue is somewhere else.

Here is my full config, you could encounter infinite recursion by nix eval .#nixosConfigurations.pc.config.fileSystems."/home/chn/.zshrc".device