From a6475e3e6082c80726ca2b0f79c9fde4556e227f Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 21 Jan 2019 17:14:22 +0900 Subject: [PATCH] git: generate identities from mail accounts (cherry picked from commit a68c8cf5f1567faf02631c6d815daad2166bf26b) --- modules/programs/git.nix | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index e8018dc1..9b7858bf 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -63,7 +63,10 @@ in type = types.package; default = pkgs.git; defaultText = "pkgs.git"; - description = "Git package to install."; + description = '' + Git package to install. Use pkgs.gitAndTools.gitFull + to gain access to git send-email for instance. + ''; }; userName = mkOption { @@ -142,6 +145,26 @@ in }; } + { + programs.git.iniContent = + let + hasSmtp = name: account: account.smtp != null; + + genIdentity = name: account: with account; + nameValuePair "sendemail.${name}" ({ + smtpEncryption = if smtp.tls.enable then "tls" else ""; + smtpServer = smtp.host; + smtpUser = userName; + from = address; + } + // optionalAttrs (smtp.port != null) { + smtpServerPort = smtp.port; + }); + in + mapAttrs' genIdentity + (filterAttrs hasSmtp config.accounts.email.accounts); + } + (mkIf (cfg.signing != null) { programs.git.iniContent = { user.signingKey = cfg.signing.key;