Deploy files into home directory with home-manager

For a long time I’ve had this home-manager config to deploy files from dotfiles into my home directory.

xdg.configFile."../" = { source = ./../dotfiles; recursive = true;};

I am upgrading from NixOS 21 to 22.11 and somehow this doesn’t work anymore: the files from dotfiles do not appear in the home directory.

I don’t see anything relevant in the changelog. What has changed? How can I fix it?

I don’t understand the difference between configFile.<name> and configFile.<name>.target but maybe that is relevant?

I don’t think that’s how it’s intended to be used in the first place. Seems more like an accident allowed .. to resolve like that in the past. You should probably use home.file instead, something like this:

home.file."${config.xdg.configHome}" = {
  source = ../../dotfiles;
  recursive = true;
};

Have you checked if changes to home-manager, rather than NixOS broke it? It’s much more likely to happen there, or be a change in how nix resolves paths.

If you haven’t updated it yet, you’re supposed to keep the home-manager branch up to date with your NixOS version, i.e. update that to 22.11 as well.

There’s no difference if you don’t set target, it defaults to the name: home-manager/file-type.nix at e412025fffdcd6219ddd21c65d9a1b90005ce508 · nix-community/home-manager · GitHub

target can be used if you want the name to be different from the target. Can be handy if you evaluate something more complex, but target == name is typically easier to read for simple cases.

Yes I tried that, didn’t find anything.

I want to put my dotfiles directly into the home directory, not into ~/.config/, so I just tried

home.file."${config.home.homeDirectory}/" = { source = ./../dotfiles; recursive = true;};

but it didn’t seem to do anything.

Thats not a valid target. when using home.file the target has to be relativ to your home. So as you want your home as root, ".", though I am pretty sure that’ll break.

Instead you really should manually specify individual folders.

Also: whenever linking home.file or xdg.*File don’t do what you expect, are there any errors during the HM activation?

1 Like

It doesn’t have to be relative, there’s code to avoid exactly that being a problem in home-manager’s fileType: home-manager/file-type.nix at e412025fffdcd6219ddd21c65d9a1b90005ce508 · nix-community/home-manager · GitHub

I have no idea what using the home directory as the target should be expected to do, either, though. You’d at the very least get really close to having recursive symlinks because your home-manager profile is in your home directory.

Oooof… Okay.

Yet another weird HM thing…

Anyway. Checking the activation for errors is still open.

Relevant issue: Allow populating home.file root with recursive dotfiles source · Issue #3849 · nix-community/home-manager · GitHub