Git's [color "status"] in home-manager

I have a working configuration of the ~/.config/git/config file with home manager.
Now, I need to add something like this:

[color "status"]
    added = green
    changed = blue
    untracked = magenta
    deleted = red

Is there an option for the above in home manager? Please advise :slight_smile:

Thanks in advance :slight_smile:

extraConfig seems to be what you are looking for.

https://nix-community.github.io/home-manager/options.html#opt-programs.git.extraConfig

Eg:

programs.git.extraConfig = {
    "color \"status\"" = { # Not too sure if there is a nicer way to avoid manual escaping.
       added = "green";
       changed = ...
    }
}

Edit: after going through the source and trying it myself, apparently you can also do something like (upon building it creates the same file)

programs.git.extraConfig = {
    color.status = {
       added = "green";
       changed = ...
    }
}
2 Likes

This is exactly what I need. Thank you very much! :slight_smile:
Bad me for missing this in the docs. Should have seen it.

1 Like