mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-18 02:44:30 +00:00
a437e9c7b6
* pre-commit-hooks: fix conditional dependency on tomli
As seen in fc88f3fa49
, upstream changed their dependency from `toml` to `tomli>=1.1.0;python_version<"3.11"`.
Without this patch, running `check-toml` from this package fails with:
```
Traceback (most recent call last):
File "/nix/store/06qpfmlgkhxakgjs8g7gk5jlkczij0m6-python3.10-pre-commit-hooks-4.3.0/bin/.check-toml-wrapped", line 6, in <module>
from pre_commit_hooks.check_toml import main
File "/nix/store/06qpfmlgkhxakgjs8g7gk5jlkczij0m6-python3.10-pre-commit-hooks-4.3.0/lib/python3.10/site-packages/pre_commit_hooks/check_toml.py", line 10, in <module>
import tomli as tomllib
ModuleNotFoundError: No module named 'tomli'
```
See https://github.com/pre-commit/pre-commit-hooks/issues/833.
* pre-commit-hooks: use lib.optionals helper for clarity
Co-authored-by: Fabian Affolter <mail@fabian-affolter.ch>
Co-authored-by: Fabian Affolter <mail@fabian-affolter.ch>
62 lines
1.3 KiB
Nix
62 lines
1.3 KiB
Nix
{ lib
|
|
, stdenv
|
|
, buildPythonPackage
|
|
, fetchFromGitHub
|
|
, git
|
|
, pytestCheckHook
|
|
, pythonOlder
|
|
, ruamel-yaml
|
|
, tomli
|
|
}:
|
|
|
|
buildPythonPackage rec {
|
|
pname = "pre-commit-hooks";
|
|
version = "4.3.0";
|
|
format = "setuptools";
|
|
|
|
disabled = pythonOlder "3.7";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "pre-commit";
|
|
repo = pname;
|
|
rev = "refs/tags/v${version}";
|
|
sha256 = "sha256-qdsSM+7ScSfxhmLAqwi1iraGHrhb5NBee/j+TKr2WUA=";
|
|
};
|
|
|
|
propagatedBuildInputs = [
|
|
ruamel-yaml
|
|
] ++ lib.optionals (pythonOlder "3.11") [
|
|
tomli
|
|
];
|
|
|
|
checkInputs = [
|
|
git
|
|
pytestCheckHook
|
|
];
|
|
|
|
# Note: this is not likely to ever work on Darwin
|
|
# https://github.com/pre-commit/pre-commit-hooks/pull/655
|
|
doCheck = !stdenv.isDarwin;
|
|
|
|
# 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"
|
|
git init .
|
|
'';
|
|
|
|
pythonImportsCheck = [
|
|
"pre_commit_hooks"
|
|
];
|
|
|
|
meta = with lib; {
|
|
description = "Some out-of-the-box hooks for pre-commit";
|
|
homepage = "https://github.com/pre-commit/pre-commit-hooks";
|
|
license = licenses.mit;
|
|
maintainers = with maintainers; [ kalbasit ];
|
|
};
|
|
}
|