Open lilyball opened 1 year ago
This issue may affect other config values that support url-specific overrides too, but I haven't checked.
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.
* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.
this also is an issue for includeIf
blocks as, if you want to use includeIf
to override some default configuration
here's an example
home.file.".config/git/<work>".text = ''
[user]
email = "<work_email>"
'';
programs.git = {
enable = true;
userName = "<username>";
userEmail = "<personal_email>";
extraConfig = {
"includeIf \"gitdir:~/Work/\"" = { path = "~/.config/git/<work>"; };
};
};
which emits
[includeIf "gitdir:~/Work/"]
path = "~/.config/git/work""
[user]
email = "<personal_email>"
name = "<username>"
@azban In your particular case you can use the built-in includes support, as those go at the end of the file.
programs.git = {
enable = true;
userName = "«username»";
userEmail = "«personal_email»";
includes = [{
condition = "gitdir:~/Work/";
contents.user.email = "«work_email»";
}];
};
Now that I've written this out, I suppose using non-conditional includes would be a possible partial workaround for my issue, as I could use multiple such files to give myself precise control over the ordering of these sections. I say partial as this requires me to write all the credential helpers myself, but other modules like programs.gh
set credentials too and so I can't necessarily achieve the control I want. If it's just gh
I can still hack it together, but if there's a second other module that sets credentials for me then it won't work.
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.
* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.
Are you following the right branch?
Is there an existing issue for this?
Issue description
Git credentials are sensitive to the order of keys across sections. In particular, it collects all
credential.helper
andcredential.<url>.helper
values in the order specified by config (where<url>
is matched against the remote), and also specifying the empty string causes it to forget all entries up to that point.In addition, the nixpkgs
git
package on darwin will include acredentia.helper=osxkeychain
entry in the system config.Given this, with
programs.gh.gitCredentialHelper.enable = true
, I end up with the following abbreviated config:And for github remotes git will therefore try
git-credential-osxkeychain
prior togh auth git-credential
. But I want to flip this order and prioritizegh auth git-credential
. The intended user config looks likeThis is currently impossible to specify with home-manager. Workarounds include specifying the empty string and osxkeychain separately for each credential host, or adding extra text directly to
xdg.configFile."git/config".text
.I don't know what the correct solution here is, given that the desired config requires having two sepearate
[credential]
sections. Credential support could potentially be moved into a separateprograms.git.credentials
option that supports this sort of ordering (though this would likely produce confusing results when putting credentials intoextraConfig
as well). Or maybe something could be done by makingextraConfig
into a submodule (with a freeform type) that makescredential
an option with special handling, although I don't know precisely what to do here.There's also potential ordering issues between the url subsections. For example, if I want to have
credential."https://github.com".helper
and then specialize one repo withcredential."https://github.com/foo/bar.git".helper
, I'd want the specialized entry to occur in the config first, but right now it will occur second (due to the default lexicographical sorting of attributes).Maintainer CC
@rycee
System information