Retroarch cores and symlinking

When you install retroarch, you can configure it in environment.systemPackages like this:
with pkgs; [(retroarch.override {cores: with libretro; […]}) …]
but when you load a rom, it stores it in its “history” json file. problem is, instead of storing the location of the core’s symlink (/run/current-system/sw/lib/retroarch/…), it stores the path from the nix store. this can be troublesome when updating and garbage collecting, as it will look for an invalid .so from the nix store. how to configure nixOS (or retroarch) to use the symlinks properly? Thanks