When to use git for nix?

I have set up nix and home-manager on macOS (with much help from @tejing - many thanks again!), and am wanting to ‘do things right’, so am checking my setup in regards to using git properly.

In this tutorial Setting up Nix on macOS from scratch (incl. dotfiles via home-manager and Nix flakes (that has a different home-management config to mine), a git repo is created in:

~/.config/ git init

and

both nix/ and nixpkgs/ directories within ~/.config are added to the git repo:

~/.config/ git add nix nixpkgs

My questions:

  1. Other than files like flakes created for home-manager and programs, are ~/.config/ (or wherever ones config/dotfiles are) and nix/ and nixpkgs/ the only directories needing git repos?

  2. If I move and/or rename a directory or file or update a flake in a git repo, what is the process to inform nix via git?

  3. I have searched for information on this subject and am failing to find it, so please share any links to a good tutorial on ‘best practices’ re the above - nix and git.

Many thanks!

Personally I think creating the repository in ~/.config is unnecessary broad and will cause a lot of pain.

The default location for HMs entrypoint is ~/.config/nixpkgs/home.nix, so I would put the repository in ~/.config/nixpkgs and have everything else in ~/.config managed through HM.

Alternatively you can have the repository anywhere and use -f to specify a file as entrypoint when running home-manager.

2 Likes

Thanks @NobbZ!

That’s solved a big point of confusion for me!!!