nixpkgs/pkgs/tools/misc/pre-commit/default.nix

58 lines
1.4 KiB
Nix
Raw Normal View History

{ lib, python3Packages }:
with python3Packages;
buildPythonPackage rec {
pname = "pre-commit";
2022-01-19 08:43:41 +00:00
version = "2.17.0";
format = "setuptools";
disabled = pythonOlder "3.6";
2018-07-30 23:19:24 +00:00
src = fetchPypi {
inherit version;
pname = "pre_commit";
2022-01-19 08:43:41 +00:00
sha256 = "c1a8040ff15ad3d648c70cc3e55b93e4d2d5b687320955505587fd79bbaed06a";
2018-07-30 23:19:24 +00:00
};
patches = [
2020-05-20 20:24:52 +00:00
./languages-use-the-hardcoded-path-to-python-binaries.patch
./hook-tmpl.patch
];
2018-07-30 23:19:24 +00:00
propagatedBuildInputs = [
cfgv
identify
nodeenv
pyyaml
2018-07-30 23:19:24 +00:00
toml
virtualenv
] ++ lib.optional (pythonOlder "3.8") [
importlib-metadata
] ++ lib.optional (pythonOlder "3.7") [
importlib-resources
];
2018-07-30 23:19:24 +00:00
# slow and impure
2018-07-30 23:19:24 +00:00
doCheck = false;
preFixup = ''
substituteInPlace $out/${python.sitePackages}/pre_commit/resources/hook-tmpl \
--subst-var-by pre-commit $out
2020-05-20 20:24:52 +00: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}
'';
pythonImportsCheck = [
"pre_commit"
];
meta = with lib; {
2018-07-30 23:19:24 +00:00
description = "A framework for managing and maintaining multi-language pre-commit hooks";
homepage = "https://pre-commit.com/";
2018-07-30 23:19:24 +00:00
license = licenses.mit;
maintainers = with maintainers; [ borisbabic ];
};
}