How do I reload XDG_DATA_DIRS varriable without logging out and logging in

I am using gnome and I found a way to have the nix app icons show on the applications menu. The problem is that when I install packages with nix, I have to log out and log back in for the app icons to show up. When you install apps with flatpak, distrobox-exports, or the system package manager, gnome automatically adds the icons to the app launcher with no need to log out and log back in. How do I get gnome to automatically have nix app icons show up on the app menu without logging out and logging back in? How does flatpak do it?

With nix-env, the desktop files will end up in ~/.nix-profile/share/applications. ~/.nix-profile is a chain of symlinks such as ~/.nix-profile/nix/var/nix/profiles/per-user/jtojnar/profile/nix/var/nix/profiles/per-user/jtojnar/profile-226-link/nix/store/38hczqbrwmsmzrqxcqjkqy35ch2bc7bc-user-environment. When a program is installed, the profile symlink would be atomically replaced with profile-227-link.

Unfortunately, GLib’s Gio library, which is used by GNOME Shell for finding installed applications does not currently notice when symlinks are modified: optionally follow symlinks when monitoring files. (#144) · Issues · GNOME / GLib · GitLab

Flatpak exports desktop files to ~/.local/share/flatpak/exports/share/applications as actual files so file monitoring works.