1
0
mirror of https://github.com/nix-community/home-manager synced 2024-07-04 20:33:27 +02:00
home-manager/tests/modules/programs/git/git-with-msmtp.nix
Andrew Fontaine aa479b0124
git: rely on msmtp for smtp if msmtp is enabled (#1829)
If a user using msmtp to send all their email, it would be preferred if
git used it as well.

The only settings necessary are to set the smtp server to the msmtp
binary and set envelop sender to true, which makes git call msmtp with
the -f flag to set the from address from the email.
2021-02-28 16:06:11 +01:00

46 lines
1.3 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
{
imports = [ ../../accounts/email-test-accounts.nix ];
config = {
accounts.email.accounts."hm@example.com".msmtp.enable = true;
programs.git = {
enable = true;
package = pkgs.gitMinimal;
userEmail = "hm@example.com";
userName = "H. M. Test";
};
home.stateVersion = "20.09";
nmt.script = ''
function assertGitConfig() {
local value
value=$(${pkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \
--get $1)
if [[ $value != $2 ]]; then
fail "Expected option '$1' to have value '$2' but it was '$value'"
fi
}
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config \
${
pkgs.substituteAll {
inherit (pkgs) msmtp;
src = ./git-with-msmtp-expected.conf;
}
}
assertGitConfig "sendemail.hm@example.com.from" "hm@example.com"
assertGitConfig "sendemail.hm-account.from" "hm@example.org"
assertGitConfig "sendemail.hm@example.com.smtpServer" "${pkgs.msmtp}/bin/msmtp"
assertGitConfig "sendemail.hm@example.com.envelopeSender" "true"
'';
};
}