nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, git
6, pytestCheckHook
7, pythonOlder
8, ruamel-yaml
9, toml
10}:
11
12buildPythonPackage rec {
13 pname = "pre-commit-hooks";
14 version = "4.2.0";
15 format = "setuptools";
16
17 disabled = pythonOlder "3.6";
18
19 src = fetchFromGitHub {
20 owner = "pre-commit";
21 repo = pname;
22 rev = "refs/tags/v${version}";
23 sha256 = "sha256-jSu4LutEgpeAbCgSHgk6VXQKLZo00T3TrQVZxsNU1co=";
24 };
25
26 propagatedBuildInputs = [
27 ruamel-yaml
28 toml
29 ];
30
31 checkInputs = [
32 git
33 pytestCheckHook
34 ];
35
36 # Note: this is not likely to ever work on Darwin
37 # https://github.com/pre-commit/pre-commit-hooks/pull/655
38 doCheck = !stdenv.isDarwin;
39
40 # the tests require a functional git installation which requires a valid HOME
41 # directory.
42 preCheck = ''
43 export HOME="$(mktemp -d)"
44
45 git config --global user.name "Nix Builder"
46 git config --global user.email "nix-builder@nixos.org"
47 git init .
48 '';
49
50 pythonImportsCheck = [
51 "pre_commit_hooks"
52 ];
53
54 meta = with lib; {
55 description = "Some out-of-the-box hooks for pre-commit";
56 homepage = "https://github.com/pre-commit/pre-commit-hooks";
57 license = licenses.mit;
58 maintainers = with maintainers; [ kalbasit ];
59 };
60}