How to manage dotfiles with home-manager?

I already have a setup with home-manager. The thing I want to know is if there is an easy way rather than doing home-manager switch every time I do a change.

For example, I have my nvim config in ~/dotfiles/config/nvim and my home-manager/home.nix has this setup:

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

This is not only for nvim, but for other configs like wezterm, a terminal that reloads the config on save.

Is there a way I could do that with home-manager? Is very tedious to change something and the need of creating a new generation just to see the new change.

Thank you!

1 Like
home.file = {
  ".config/nvim" = {
    source = config.lib.file.mkOutOfStoreSymlink ../config/nvim;
  };
}

btw if you are using flakes you need to use abslute path as string like:

home.file = {
  ".config/nvim" = {
    source = config.lib.file.mkOutOfStoreSymlink "/home/algus/dotfiles/config/nvim"
  };

if you pass a path instead of string on flakes like in:

home.file = {
  ".config/nvim" = {
    source = config.lib.file.mkOutOfStoreSymlink ../config/nvim;
  };
}

it will copy your config to store before creating a symlink and you will need to home-manager switch --flake everytime (note: --impure might bypass copying i didint tried tough)

note: you can use functions to abstract some of abslute paths

1 Like

Amazing. Thanks for the help :smiley:
This makes it a lot easier for these kind of configurations

1 Like