2021-07-10 17:41:22 +02:00
|
|
|
{ lib
|
2021-12-28 00:05:44 +01:00
|
|
|
, stdenv
|
2021-07-10 17:41:22 +02:00
|
|
|
, buildPythonPackage
|
2020-12-14 10:52:20 -08:00
|
|
|
, fetchFromGitHub
|
|
|
|
, git
|
|
|
|
, pytestCheckHook
|
2021-12-28 00:05:44 +01:00
|
|
|
, pythonOlder
|
2021-11-01 21:59:40 +01:00
|
|
|
, ruamel-yaml
|
2022-11-18 14:52:28 +00:00
|
|
|
, tomli
|
2020-12-14 10:52:20 -08:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pre-commit-hooks";
|
2022-12-18 21:40:01 +01:00
|
|
|
version = "4.4.0";
|
2021-12-28 00:05:44 +01:00
|
|
|
format = "setuptools";
|
|
|
|
|
2022-06-08 21:52:33 +02:00
|
|
|
disabled = pythonOlder "3.7";
|
2020-12-14 10:52:20 -08:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pre-commit";
|
|
|
|
repo = pname;
|
2022-04-07 15:06:01 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2022-12-18 21:40:01 +01:00
|
|
|
hash = "sha256-V23pgHQ9GdZ2mukFEMAhkp+dl/CQTGxWHAhF7s1VvHo=";
|
2020-12-14 10:52:20 -08:00
|
|
|
};
|
|
|
|
|
2021-07-10 17:41:22 +02:00
|
|
|
propagatedBuildInputs = [
|
2021-11-01 21:59:40 +01:00
|
|
|
ruamel-yaml
|
2022-11-18 14:52:28 +00:00
|
|
|
] ++ lib.optionals (pythonOlder "3.11") [
|
|
|
|
tomli
|
2021-07-10 17:41:22 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
checkInputs = [
|
|
|
|
git
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
2020-12-14 10:52:20 -08:00
|
|
|
|
2021-12-06 16:05:43 -05: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-14 10:52:20 -08: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-28 00:05:44 +01:00
|
|
|
git init .
|
2020-12-14 10:52:20 -08:00
|
|
|
'';
|
|
|
|
|
2021-12-28 00:05:44 +01:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"pre_commit_hooks"
|
|
|
|
];
|
2021-07-10 17:41:22 +02:00
|
|
|
|
2020-12-14 10:52:20 -08: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-18 21:37:21 +01:00
|
|
|
changelog = "https://github.com/pre-commit/pre-commit-hooks/blob/v${version}/CHANGELOG.md";
|
2020-12-14 10:52:20 -08:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ kalbasit ];
|
|
|
|
};
|
|
|
|
}
|