1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-18 17:19:45 +01:00
home-manager/tests/modules/programs/git/git-with-hooks.nix

27 lines
693 B
Nix
Raw Normal View History

2022-09-04 18:57:45 +02:00
{ pkgs, ... }:
{
programs.git = {
enable = true;
hooks = { pre-commit = ./git-pre-commit-hook.sh; };
};
nmt.script = ''
function getGitConfig() {
${pkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \
--get $1
}
assertFileExists home-files/.config/git/config
hookPath=$(getGitConfig core.hooksPath)
assertLinkExists $hookPath/pre-commit
actual="$(readlink "$hookPath/pre-commit")"
expected="${./git-pre-commit-hook.sh}"
if [[ $actual != $expected ]]; then
fail "Symlink $hookPath/pre-commit should point to $expected via the Nix store, but it actually points to $actual."
fi
'';
}