Helping a program find its config file


I’m trying to package my config file for a certain program (emulationstation) inside the Nix store for easy deployment purposes with NixOps. I was hoping I can pass a config path parameter to the program, but lo and behold it reads from the hardcoded path $HOME/.emulationstation/es_systems.cfg.

What are my options here going forward? Should I use symlinks, or are there more clever ways of handling this issue?


  • Rasmus

I’d say it depends on how much work you want to put in and how exactly the program is working.
The best option in that regard is probably to suggest a patch to upstream or ask them to provide an option to override the config path. Until upstream has that option, you could patch it in the build script.

If it’s being run as a service, you could create/change a link in an ExecStartPre script. Or try to fiddle with mount trickery, but that’s probably not worth it.

If it’s run manually by a user, you could create a wrapper that creates or changes the link when it’s started.

I think home-manager is the typical NixOS user’s way to solve this.

  home.file.".emulationstation/es_systems.cfg".source = ./es_systems.cfg;
1 Like

Thanks for the suggestions! I’ll see if I can patch the program to read from custom config paths, and try home manager if not.