nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.08k stars 1.82k forks source link

`accounts.email.accounts.<name>.userName` must be defined when `programs.git` is enabled #3712

Open qaristote opened 1 year ago

qaristote commented 1 year ago

I have defined an email account with

accounts.email.accounts.personal = { ... };

but didn't specify a userName as for IMAP and SMTP it's the same as the address. I have also enabled git with

programs.git.enable = true;

When building my configuration, I got

error: A definition for option `home-manager.users.qaristote.programs.git.iniContent."sendemail.personal".smtpUser' is not of type `string or boolean or signed integer or list of (string or boolean or signed integer) or attribute set of (string or boolean or signed integer or list of (string or boolean or signed integer))'. Definition values:

I believe the lines at fault are the following: https://github.com/nix-community/home-manager/blob/ab7c8f4a8427bfcaf01a46bab974298cc27bc1f5/modules/programs/git.nix#L435-L464

and that a simple fix would be to replace

smtpUser = userName;

with

smtpUser = if (userName != null) then userName else address;

but I'll let you see that for yourself :)

ncfavier commented 1 year ago

if (userName != null) then userName else address should work, do you want to open a PR?

qaristote commented 1 year ago

Yeah my bad. Another solution would be to set the default value of userName to the value of address. I'd rather let the maintainers choose between these solutions and create the PR accordingly !

rycee commented 1 year ago

I don't recall why the userName option has type types.nullOr types.str. Seems to me that it should always be given. Then you would have gotten a better error message. It doesn't seem so nice to just assume that the user name is the same as the email address, better make it clear that it is needed.

stale[bot] commented 1 year ago

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 you are the original author of the issue

* 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 not the original author of the 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.

Memorandum on closing issues

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.

haennes commented 2 weeks ago

I don't recall why the userName option has type types.nullOr types.str. Seems to me that it should always be given. Then you would have gotten a better error message. It doesn't seem so nice to just assume that the user name is the same as the email address, better make it clear that it is needed.

Should i make a PR that changes the type to just be types.str ?