Issues with recursively symlinking config files with Home Manager

I’m currently using Home Manager to symlink some config files that aren’t done in Nix, and while they mostly work well, I’m having some issues with doing so recursively.
I have a file structure like:

nonnix/
  tmux/
    tmux.conf
    plugins/

where the plugins folder is filled with different folders for the plugins.
My code to symlink the folder is the following:

home.file.".config/tmux" = {
  source = config.lib.file.mkOutOfStoreSymlink ../nonnix/tmux;
  recursive = true;
};

and using this, I was able to symlink some of my other config files, but for this one, it only symlinks the tmux.conf file, not the plugins/ folder inside. Any ideas or ways to fix this? I’ve looked for a bit, but I wasn’t able to find a way to do this that worked for me. Thanks!

1 Like

I’m curious about the reasoning behind the symlinks. How does it work? Is it the only way Home Manager can apply dotfiles that aren’t done in Nix? If not why did you chose this method in particular?

1 Like

The reason why is that I simply didn’t feel like using Home Manager to do my configs for tmux, emacs, and neovim, but I still wanted those dotfiles inside of the /etc/nixos directory (so that I could back them up on the same Git repository) and symlinking them was just the easiest solution in my mind, and I’m not sure if this is the only way Home Manager can symlink files? I wasn’t able to find many other solutions.
And I’m not sure what you mean by how it works, inside of my /etc/nixos/ directory I have a folder called nonnix/ and I just symlink the different folders inside of it as shown in the original post.

1 Like

Since it’s in the same git repository, you should be able to just pass the file’s path directly.
Like so:

home.file.".config/tmux" = {
  source = ../nonnix/tmux;
  recursive = true;
};

Also, unless you need every file in the directory to be individually symlinked rather than the directory as a whole, you should probably remove recursive = true;

For more information, I would recommend using the home manager option search and looking at the documentation for home.file and its sub-options: https://home-manager-options.extranix.com

2 Likes

I tried passing in the file path directly, but I’m still getting the issue where the symlinked tmux/plugins/ folder is blank, thank you so much for the documentation search though!

1 Like

Is the source directory and its contents all tracked by git? Nix will only see files that are tracked by the git repo.

1 Like

Yup! My initial issue where the plugins/ folder wasn’t getting symlinked at all was because it wasn’t tracked, but the contents of the folder still aren’t being symlinked.