2021-07-14 22:03:04 +00:00
|
|
|
{ lib
|
2021-12-30 13:39:12 +00:00
|
|
|
, stdenv
|
2021-07-14 22:03:04 +00:00
|
|
|
, buildPythonPackage
|
2020-12-25 13:55:36 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, git
|
|
|
|
, pytestCheckHook
|
2021-12-30 13:39:12 +00:00
|
|
|
, pythonOlder
|
2021-12-06 16:07:01 +00:00
|
|
|
, ruamel-yaml
|
2022-11-21 17:40:18 +00:00
|
|
|
, tomli
|
2020-12-25 13:55:36 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pre-commit-hooks";
|
2022-12-28 21:21:41 +00:00
|
|
|
version = "4.4.0";
|
2021-12-30 13:39:12 +00:00
|
|
|
format = "setuptools";
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2020-12-25 13:55:36 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pre-commit";
|
|
|
|
repo = pname;
|
2022-04-15 01:41:22 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2022-12-28 21:21:41 +00:00
|
|
|
hash = "sha256-V23pgHQ9GdZ2mukFEMAhkp+dl/CQTGxWHAhF7s1VvHo=";
|
2020-12-25 13:55:36 +00:00
|
|
|
};
|
|
|
|
|
2021-07-14 22:03:04 +00:00
|
|
|
propagatedBuildInputs = [
|
2021-12-06 16:07:01 +00:00
|
|
|
ruamel-yaml
|
2022-11-21 17:40:18 +00:00
|
|
|
] ++ lib.optionals (pythonOlder "3.11") [
|
|
|
|
tomli
|
2021-07-14 22:03:04 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
checkInputs = [
|
|
|
|
git
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
2020-12-25 13:55:36 +00:00
|
|
|
|
2021-12-24 04:21:11 +00:00
|
|
|
# Note: this is not likely to ever work on Darwin
|
|
|
|
# https://github.com/pre-commit/pre-commit-hooks/pull/655
|
|
|
|
doCheck = !stdenv.isDarwin;
|
|
|
|
|
2020-12-25 13:55:36 +00:00
|
|
|
# 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"
|
2021-12-30 13:39:12 +00:00
|
|
|
git init .
|
2020-12-25 13:55:36 +00:00
|
|
|
'';
|
|
|
|
|
2021-12-30 13:39:12 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"pre_commit_hooks"
|
|
|
|
];
|
2021-07-14 22:03:04 +00:00
|
|
|
|
2020-12-25 13:55:36 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Some out-of-the-box hooks for pre-commit";
|
|
|
|
homepage = "https://github.com/pre-commit/pre-commit-hooks";
|
2022-12-28 21:21:41 +00:00
|
|
|
changelog = "https://github.com/pre-commit/pre-commit-hooks/blob/v${version}/CHANGELOG.md";
|
2020-12-25 13:55:36 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ kalbasit ];
|
|
|
|
};
|
|
|
|
}
|