fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Charlie Mooggit: add config helper for hooks340ec22f

master
693 B26 linesraw
1{ pkgs, ... }:
2
3{
4  programs.git = {
5    enable = true;
6    hooks = { pre-commit = ./git-pre-commit-hook.sh; };
7  };
8
9  nmt.script = ''
10    function getGitConfig() {
11      ${pkgs.gitMinimal}/bin/git config \
12        --file $TESTED/home-files/.config/git/config \
13        --get $1
14    }
15
16    assertFileExists home-files/.config/git/config
17    hookPath=$(getGitConfig core.hooksPath)
18    assertLinkExists $hookPath/pre-commit
19
20    actual="$(readlink "$hookPath/pre-commit")"
21    expected="${./git-pre-commit-hook.sh}"
22    if [[ $actual != $expected ]]; then
23      fail "Symlink $hookPath/pre-commit should point to $expected via the Nix store, but it actually points to $actual."
24    fi
25  '';
26}