Customizing system-wide configuration files in packages

I use R and I want to customize Rprofile.site. That file should be in /nix/store/...-R-4.0.2/lib64/R/etc but I don’t want to change the derivation for R because that would recompile R every time I tweak Rprofile.site. Are there other approaches? Would something like having a separate derivation just for that file, then using symlinkJoin to combine it with R help?

according to R: Initialization at Start of an R Session the R_PROFILE envvar can be used.

If you’re “consuming” these packages through a shell.nix, you could just add this to the shellHook

And if you have installed R systemd wide you could try environment.variables.R_PROFILE = ...;

Since I need a docker image using non-NixOS as base I am going with R_PROFILE approach. Still this is very specific to one file for one application. Is there an approach that could be used for any application that needs global configuration files? Btw I am now having much more serious issues with R from nixpkgs (Improving NixOS data science infrastructure: CI for MKL&CUDA - #50 by alexv).