Hacker News new | ask | show | jobs
by AgentElement 265 days ago
With nix + home manager, you can use `mkOutOfStoreSymlink` to make symlinks between the dotfile repo and the target destination in `.config`. I've found this to be the most ergonomic way to have nix-managed dotfiles. Because the out-of-store dotfile repo is symlinked, you can make little changes to your system without doing the whole commit and switch dance.

For example, here's a snippet pulled from my dotfiles that does this for multiple dotfiles at once:

  home.file =
    builtins.mapAttrs
      (key: value: {
        # symlink ~/dotfiles/configs/{value} to ~/{key}
        source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dotfiles/configs/${value}";
      })
      {
        ".zshrc"                                    = "zsh/zshrc";
        ".p10k.zsh"                                 = "zsh/p10k.zsh";
        ".config/sway/config"                       = "sway/config";
        ".config/nvim/init.lua"                     = "nvim/init.lua";
      };
2 comments

Oh right, I do this too!

At the same time it often feels like a veneer of control, like you can control exactly where to place the door, but what's in the messy room (like emacs profiles if you do that) might be hidden behind the very nice and solid door.

It's like in python projects I lock python3 and uv, and beyond that it's wild west. Still beats everything else, still feels a bit incomplete, and still feels somewhat unresolvable.

Caveat: This works for literal dotfiles in your repo but it doesn’t help you if you use nix declared config, e.g. programs.git