Best way to handle hardcoded paths in a cross-platform Neovim flake?

Hi all,

I have a flake that lets me use my Neovim setup from my Linux machine on other hosts. I’d like to use the same setup on my work MacBook, but I’m not sure of the best way to handle some hardcoded paths in my config.

On Linux, I point to files that don’t exist on my work machine, but I do have equivalent files there.

Would it be better to:
• Replace these paths with environment variables (set in zshrc or via Home Manager) and define them differently per machine, or
• Use a more Nix-native approach, such as conditional configuration in Home Manager (e.g. config.system, config.home.sessionVariables, or platform-specific modules)?

I’m already using Home Manager, so I’m open to structuring things properly there if that’s the more robust solution.

I’d appreciate any guidance or examples of how others have solved this problem.

Thanks!

Or an even more Nix-native approach like nixvim.

I am using nixvim, standalone, with the advanced makeNixvimWithModule, to make it portable.

Other solution (nvf):

Hi thanks for the suggestions, I’m already using NVF, however this doesn’t address the issue with hard coded paths.