1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, git
6, pytestCheckHook
7, pythonOlder
8, ruamel-yaml
9, tomli
10}:
11
12buildPythonPackage rec {
13 pname = "pre-commit-hooks";
14 version = "4.3.0";
15 format = "setuptools";
16
17 disabled = pythonOlder "3.7";
18
19 src = fetchFromGitHub {
20 owner = "pre-commit";
21 repo = pname;
22 rev = "refs/tags/v${version}";
23 sha256 = "sha256-qdsSM+7ScSfxhmLAqwi1iraGHrhb5NBee/j+TKr2WUA=";
24 };
25
26 propagatedBuildInputs = [
27 ruamel-yaml
28 ] ++ lib.optionals (pythonOlder "3.11") [
29 tomli
30 ];
31
32 checkInputs = [
33 git
34 pytestCheckHook
35 ];
36
37 # Note: this is not likely to ever work on Darwin
38 # https://github.com/pre-commit/pre-commit-hooks/pull/655
39 doCheck = !stdenv.isDarwin;
40
41 # the tests require a functional git installation which requires a valid HOME
42 # directory.
43 preCheck = ''
44 export HOME="$(mktemp -d)"
45
46 git config --global user.name "Nix Builder"
47 git config --global user.email "nix-builder@nixos.org"
48 git init .
49 '';
50
51 pythonImportsCheck = [
52 "pre_commit_hooks"
53 ];
54
55 meta = with lib; {
56 description = "Some out-of-the-box hooks for pre-commit";
57 homepage = "https://github.com/pre-commit/pre-commit-hooks";
58 license = licenses.mit;
59 maintainers = with maintainers; [ kalbasit ];
60 };
61}