Home-manager home.file multi sourcing


I’m refactoring my Nix configuration, and along the way I saw that I will need to do something that, in fact, can’t be done by default and I don’t know how to get around it either:

I have the configuration of a program split into two folders in my Nix configuration:


My intention is that, using the home.file attribute of home-manager, I can create the respective link in the program configuration that, in the same directory, has file_1 and file_2. That is to say, I need that the directory of my home looks like this


The problem is that home.file only allows one source, so something like:

home.file = {
  "user/.config/program" = {
      source = { .../dir_1, .../dir_2}; 
      recursive = true;

It doesn’t work. And of course, much less create two entries with the same attribute. So, does anyone know how to get around the problem? Is it possible to “concatenate” the content of two directories and pass it as a path to “source”?

Thank you very much for your help!

Additional info: In case it helps, each folder will have more than one file, that’s why I add the recursive.

I don’t think is possible with home.file since code test for this

Maybe you can use symlinkJoin to concatenate path and set result as source.

just link the individual files instead of trying to merge directories:

{ home.file = {
  "user/.config/program/file_1" = {
      source = .../dir_1/file_1;

  "user/.config/program/file_2" = {
      source = .../dir_2/file_2;

Yes, I saw that too :cry: but your proposal to use symlinkJoin looks very promising to me! I will try that way.

That’s what I’m doing at the moment, however, both directories will have a lot of files, and I change them frequently, so this solution may be tedious in the long run. Still thanks for the reply, it took me a couple of hours to remember that I could do it as a workaround!

Thanks you both for your answers. I will report back if I am successful with the alternative.

The target is not same though. The program/file_1 and program/file_2 are different files.