Home-manager: how to set git username based on folder?

I have a folder for work repos and one for personal ones, and I’d like to set different name and email for each. I know this is possible using git conditionals, but I can’t find how to do this with home-manager. Is this possible? And if so, how?

Note that I’m very new to home-manager, so you can assume I know nothing, and if I do it’s good repetition :smiley:

Figured it out! I had to do the following:

{
  programs.git = {
    enable = true;
    includes = [
      { # personal
        condition = "gitdir:~/Dev/";
        contents.user = {
          email = "peronal@email.com";
          name = "My Name";
        };
      }
      { # work
        condition = "gitdir:~/Work/";
        contents.user = {
          email = "work@email.com";
          name = "My Name";
        };
      }
    ];
  };
}
2 Likes