about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/pre-commit-hooks/default.nix
blob: f5fe7ff96b84240499c5585980f505d6161c443e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ buildPythonPackage
, fetchFromGitHub
, fetchPypi
, git
, isPy27
, lib
, pytestCheckHook
, ruamel_yaml
, toml
}:

buildPythonPackage rec {
  pname = "pre-commit-hooks";
  version = "3.3.0";
  disabled = isPy27;

  # fetchPypi does not provide tests
  src = fetchFromGitHub {
    owner = "pre-commit";
    repo = pname;
    rev = "v${version}";
    sha256 = "1sppwcqsbr9gv2cpjslngcbggsxvdr84zgrin94yjr40jgkjzdpq";
  };

  propagatedBuildInputs = [ toml ruamel_yaml ];
  checkInputs = [ git pytestCheckHook ];

  # the tests require a functional git installation which requires a valid HOME
  # directory.
  preCheck = ''
    export HOME="$(mktemp -d)"

    git config --global user.name "Nix Builder"
    git config --global user.email "nix-builder@nixos.org"
  '';

  meta = with lib; {
    description = "Some out-of-the-box hooks for pre-commit";
    homepage = "https://github.com/pre-commit/pre-commit-hooks";
    license = licenses.mit;
    maintainers = with maintainers; [ kalbasit ];
  };
}