Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, fetchPypi
3, buildPythonPackage
4, pythonOlder
5, aspy-yaml
6, cached-property
7, cfgv
8, identify
9, importlib-metadata
10, importlib-resources
11, nodeenv
12, python
13, six
14, toml
15, virtualenv
16}:
17
18buildPythonPackage rec {
19 pname = "pre-commit";
20 version = "2.15.0";
21 disabled = pythonOlder "3.6";
22
23 src = fetchPypi {
24 inherit version;
25 pname = "pre_commit";
26 sha256 = "sha256-PCWt1429+2ooplF4DVwxGsQN0X8WDrOVSgxZ2kClBac=";
27 };
28
29 patches = [
30 ./hook-tmpl-use-the-hardcoded-path-to-pre-commit.patch
31 ./languages-use-the-hardcoded-path-to-python-binaries.patch
32 ];
33
34 propagatedBuildInputs = [
35 aspy-yaml
36 cached-property
37 cfgv
38 identify
39 nodeenv
40 six
41 toml
42 virtualenv
43 ] ++ lib.optional (pythonOlder "3.8") importlib-metadata
44 ++ lib.optional (pythonOlder "3.7") importlib-resources;
45
46 # slow and impure
47 doCheck = false;
48
49 preFixup = ''
50 substituteInPlace $out/${python.sitePackages}/pre_commit/resources/hook-tmpl \
51 --subst-var-by pre-commit $out
52 substituteInPlace $out/${python.sitePackages}/pre_commit/languages/python.py \
53 --subst-var-by virtualenv ${virtualenv}
54 substituteInPlace $out/${python.sitePackages}/pre_commit/languages/node.py \
55 --subst-var-by nodeenv ${nodeenv}
56 '';
57
58 pythonImportsCheck = [ "pre_commit" ];
59
60 meta = with lib; {
61 description = "A framework for managing and maintaining multi-language pre-commit hooks";
62 homepage = "https://pre-commit.com/";
63 license = licenses.mit;
64 maintainers = with maintainers; [ borisbabic ];
65 };
66}