2021-06-10 11:19:28 +01:00
|
|
|
{ lib
|
|
|
|
, fetchPypi
|
|
|
|
, buildPythonPackage
|
|
|
|
, pythonOlder
|
2019-08-09 20:24:08 +01:00
|
|
|
, aspy-yaml
|
|
|
|
, cached-property
|
|
|
|
, cfgv
|
|
|
|
, identify
|
|
|
|
, importlib-metadata
|
|
|
|
, importlib-resources
|
|
|
|
, nodeenv
|
2020-02-01 18:05:42 +00:00
|
|
|
, python
|
2019-08-09 20:24:08 +01:00
|
|
|
, six
|
|
|
|
, toml
|
|
|
|
, virtualenv
|
|
|
|
}:
|
|
|
|
|
2020-05-20 11:22:47 +01:00
|
|
|
buildPythonPackage rec {
|
2019-01-24 19:50:13 +00:00
|
|
|
pname = "pre-commit";
|
2021-09-10 16:19:09 +01:00
|
|
|
version = "2.15.0";
|
2021-06-10 11:19:28 +01:00
|
|
|
disabled = pythonOlder "3.6";
|
2018-07-31 00:19:24 +01:00
|
|
|
|
|
|
|
src = fetchPypi {
|
2019-01-24 19:50:13 +00:00
|
|
|
inherit version;
|
|
|
|
pname = "pre_commit";
|
2021-09-10 16:19:09 +01:00
|
|
|
sha256 = "sha256-PCWt1429+2ooplF4DVwxGsQN0X8WDrOVSgxZ2kClBac=";
|
2018-07-31 00:19:24 +01:00
|
|
|
};
|
|
|
|
|
2020-02-01 18:05:42 +00:00
|
|
|
patches = [
|
|
|
|
./hook-tmpl-use-the-hardcoded-path-to-pre-commit.patch
|
2020-05-20 21:24:52 +01:00
|
|
|
./languages-use-the-hardcoded-path-to-python-binaries.patch
|
2020-02-01 18:05:42 +00:00
|
|
|
];
|
|
|
|
|
2018-07-31 00:19:24 +01:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
aspy-yaml
|
|
|
|
cached-property
|
|
|
|
cfgv
|
|
|
|
identify
|
|
|
|
nodeenv
|
|
|
|
six
|
|
|
|
toml
|
|
|
|
virtualenv
|
2020-05-20 21:24:52 +01:00
|
|
|
] ++ lib.optional (pythonOlder "3.8") importlib-metadata
|
|
|
|
++ lib.optional (pythonOlder "3.7") importlib-resources;
|
2018-07-31 00:19:24 +01:00
|
|
|
|
2019-08-09 20:24:08 +01:00
|
|
|
# slow and impure
|
2018-07-31 00:19:24 +01:00
|
|
|
doCheck = false;
|
|
|
|
|
2020-02-01 18:05:42 +00:00
|
|
|
preFixup = ''
|
|
|
|
substituteInPlace $out/${python.sitePackages}/pre_commit/resources/hook-tmpl \
|
|
|
|
--subst-var-by pre-commit $out
|
2020-05-20 21:24:52 +01:00
|
|
|
substituteInPlace $out/${python.sitePackages}/pre_commit/languages/python.py \
|
|
|
|
--subst-var-by virtualenv ${virtualenv}
|
|
|
|
substituteInPlace $out/${python.sitePackages}/pre_commit/languages/node.py \
|
|
|
|
--subst-var-by nodeenv ${nodeenv}
|
2020-02-01 18:05:42 +00:00
|
|
|
'';
|
|
|
|
|
2021-06-10 11:19:28 +01:00
|
|
|
pythonImportsCheck = [ "pre_commit" ];
|
|
|
|
|
2019-08-09 20:24:08 +01:00
|
|
|
meta = with lib; {
|
2018-07-31 00:19:24 +01:00
|
|
|
description = "A framework for managing and maintaining multi-language pre-commit hooks";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://pre-commit.com/";
|
2018-07-31 00:19:24 +01:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ borisbabic ];
|
|
|
|
};
|
|
|
|
}
|