2022-04-04 19:28:00 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
2023-02-09 02:58:07 +00:00
|
|
|
, python3Packages
|
|
|
|
, libiconv
|
2022-04-04 19:28:00 +00:00
|
|
|
, cargo
|
2023-02-09 02:58:07 +00:00
|
|
|
, coursier
|
2022-04-04 19:28:00 +00:00
|
|
|
, dotnet-sdk
|
|
|
|
, git
|
2023-02-09 02:58:07 +00:00
|
|
|
, glibcLocales
|
2022-04-04 19:28:00 +00:00
|
|
|
, go
|
|
|
|
, nodejs
|
2023-02-09 02:58:07 +00:00
|
|
|
, perl
|
2023-12-10 02:42:33 +00:00
|
|
|
, cabal-install
|
2023-02-09 02:58:07 +00:00
|
|
|
, testers
|
|
|
|
, pre-commit
|
2022-04-04 19:28:00 +00:00
|
|
|
}:
|
2019-08-09 19:24:08 +00:00
|
|
|
|
2021-12-04 14:21:29 +00:00
|
|
|
with python3Packages;
|
2023-02-09 02:58:07 +00:00
|
|
|
buildPythonApplication rec {
|
2019-01-24 19:50:13 +00:00
|
|
|
pname = "pre-commit";
|
2024-05-12 11:38:55 +00:00
|
|
|
version = "3.7.1";
|
2021-12-01 10:57:53 +00:00
|
|
|
format = "setuptools";
|
|
|
|
|
2023-12-10 02:42:33 +00:00
|
|
|
disabled = pythonOlder "3.9";
|
2018-07-30 23:19:24 +00:00
|
|
|
|
2022-04-04 19:28:00 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pre-commit";
|
|
|
|
repo = "pre-commit";
|
2024-02-13 20:51:22 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-05-12 11:38:55 +00:00
|
|
|
hash = "sha256-+9NNXM4i6saxktF1pl93dmkrqjsErqMB6kEK3IPQTNQ=";
|
2018-07-30 23:19:24 +00:00
|
|
|
};
|
|
|
|
|
2020-02-01 18:05:42 +00:00
|
|
|
patches = [
|
2020-05-20 20:24:52 +00:00
|
|
|
./languages-use-the-hardcoded-path-to-python-binaries.patch
|
2021-12-02 22:51:24 +00:00
|
|
|
./hook-tmpl.patch
|
2023-12-28 03:43:44 +00:00
|
|
|
./pygrep-pythonpath.patch
|
2020-02-01 18:05:42 +00:00
|
|
|
];
|
|
|
|
|
2018-07-30 23:19:24 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
cfgv
|
|
|
|
identify
|
|
|
|
nodeenv
|
2021-12-01 10:57:53 +00:00
|
|
|
pyyaml
|
2018-07-30 23:19:24 +00:00
|
|
|
toml
|
|
|
|
virtualenv
|
2021-12-01 10:57:53 +00:00
|
|
|
];
|
2018-07-30 23:19:24 +00:00
|
|
|
|
2023-01-21 12:00:00 +00:00
|
|
|
nativeCheckInputs = [
|
2022-04-04 19:28:00 +00:00
|
|
|
cargo
|
2023-02-09 02:58:07 +00:00
|
|
|
coursier
|
2022-04-04 19:28:00 +00:00
|
|
|
dotnet-sdk
|
|
|
|
git
|
2023-02-09 02:58:07 +00:00
|
|
|
glibcLocales
|
2022-04-04 19:28:00 +00:00
|
|
|
go
|
2023-02-09 02:58:07 +00:00
|
|
|
libiconv # For rust tests on Darwin
|
2022-04-04 19:28:00 +00:00
|
|
|
nodejs
|
2023-02-09 02:58:07 +00:00
|
|
|
perl
|
2022-04-04 19:28:00 +00:00
|
|
|
pytest-env
|
2023-01-03 05:14:11 +00:00
|
|
|
pytest-forked
|
2022-04-04 19:28:00 +00:00
|
|
|
pytest-xdist
|
|
|
|
pytestCheckHook
|
|
|
|
re-assert
|
2023-12-10 02:42:33 +00:00
|
|
|
cabal-install
|
2022-04-04 19:28:00 +00:00
|
|
|
];
|
|
|
|
|
2023-02-03 19:40:34 +00:00
|
|
|
# i686-linux: dotnet-sdk not available
|
|
|
|
doCheck = stdenv.buildPlatform.system != "i686-linux";
|
2018-07-30 23:19:24 +00:00
|
|
|
|
2022-04-04 19:28:00 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace pre_commit/resources/hook-tmpl \
|
2020-02-01 18:05:42 +00:00
|
|
|
--subst-var-by pre-commit $out
|
2022-04-04 19:28:00 +00:00
|
|
|
substituteInPlace pre_commit/languages/python.py \
|
2020-05-20 20:24:52 +00:00
|
|
|
--subst-var-by virtualenv ${virtualenv}
|
2022-04-04 19:28:00 +00:00
|
|
|
substituteInPlace pre_commit/languages/node.py \
|
2020-05-20 20:24:52 +00:00
|
|
|
--subst-var-by nodeenv ${nodeenv}
|
2022-04-04 19:28:00 +00:00
|
|
|
|
|
|
|
patchShebangs pre_commit/resources/hook-tmpl
|
|
|
|
'';
|
|
|
|
|
|
|
|
pytestFlagsArray = [
|
|
|
|
"--forked"
|
|
|
|
];
|
|
|
|
|
2023-02-09 02:58:07 +00:00
|
|
|
preCheck = lib.optionalString (!(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64)) ''
|
|
|
|
# Disable outline atomics for rust tests on aarch64-linux.
|
|
|
|
export RUSTFLAGS="-Ctarget-feature=-outline-atomics"
|
|
|
|
'' + ''
|
2022-04-04 19:28:00 +00:00
|
|
|
export GIT_AUTHOR_NAME=test GIT_COMMITTER_NAME=test \
|
|
|
|
GIT_AUTHOR_EMAIL=test@example.com GIT_COMMITTER_EMAIL=test@example.com \
|
|
|
|
VIRTUALENV_NO_DOWNLOAD=1 PRE_COMMIT_NO_CONCURRENCY=1 LANG=en_US.UTF-8
|
|
|
|
|
2023-02-09 02:58:07 +00:00
|
|
|
# Resolve `.NET location: Not found` errors for dotnet tests
|
|
|
|
export DOTNET_ROOT="${dotnet-sdk}"
|
2022-04-04 19:28:00 +00:00
|
|
|
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
|
2023-02-09 02:58:07 +00:00
|
|
|
git init -b master
|
|
|
|
|
2022-04-04 19:28:00 +00:00
|
|
|
python -m venv --system-site-packages venv
|
|
|
|
source "$PWD/venv/bin/activate"
|
2020-02-01 18:05:42 +00:00
|
|
|
'';
|
|
|
|
|
2022-04-04 19:28:00 +00:00
|
|
|
postCheck = ''
|
|
|
|
deactivate
|
|
|
|
'';
|
|
|
|
|
2023-05-31 03:47:31 +00:00
|
|
|
# Propagating dependencies leaks them through $PYTHONPATH which causes issues
|
|
|
|
# when used in nix-shell.
|
|
|
|
postFixup = ''
|
|
|
|
rm $out/nix-support/propagated-build-inputs
|
|
|
|
'';
|
|
|
|
|
2022-04-04 19:28:00 +00:00
|
|
|
disabledTests = [
|
|
|
|
# ERROR: The install method you used for conda--probably either `pip install conda`
|
|
|
|
# or `easy_install conda`--is not compatible with using conda as an application.
|
|
|
|
"test_conda_"
|
|
|
|
"test_local_conda_"
|
|
|
|
|
|
|
|
# /build/pytest-of-nixbld/pytest-0/test_install_ruby_with_version0/rbenv-2.7.2/libexec/rbenv-init:
|
|
|
|
# /usr/bin/env: bad interpreter: No such file or directory
|
2023-02-09 02:58:07 +00:00
|
|
|
"test_ruby_"
|
2022-04-04 19:28:00 +00:00
|
|
|
|
|
|
|
# network
|
|
|
|
"test_additional_dependencies_roll_forward"
|
|
|
|
"test_additional_golang_dependencies_installed"
|
|
|
|
"test_additional_node_dependencies_installed"
|
|
|
|
"test_additional_rust_cli_dependencies_installed"
|
|
|
|
"test_additional_rust_lib_dependencies_installed"
|
2023-02-09 02:58:07 +00:00
|
|
|
"test_coursier_hook"
|
|
|
|
"test_coursier_hook_additional_dependencies"
|
|
|
|
"test_dart"
|
|
|
|
"test_dart_additional_deps"
|
|
|
|
"test_dart_additional_deps_versioned"
|
2024-03-02 14:37:28 +00:00
|
|
|
"test_during_commit_all"
|
2023-02-09 02:58:07 +00:00
|
|
|
"test_golang_default_version"
|
2022-04-04 19:28:00 +00:00
|
|
|
"test_golang_hook"
|
|
|
|
"test_golang_hook_still_works_when_gobin_is_set"
|
2023-02-09 02:58:07 +00:00
|
|
|
"test_golang_infer_go_version_default"
|
|
|
|
"test_golang_system"
|
|
|
|
"test_golang_versioned"
|
|
|
|
"test_language_version_with_rustup"
|
|
|
|
"test_installs_rust_missing_rustup"
|
2022-04-04 19:28:00 +00:00
|
|
|
"test_installs_without_links_outside_env"
|
2023-02-09 02:58:07 +00:00
|
|
|
"test_local_golang_additional_deps"
|
|
|
|
"test_lua"
|
|
|
|
"test_lua_additional_dependencies"
|
|
|
|
"test_node_additional_deps"
|
|
|
|
"test_node_hook_versions"
|
|
|
|
"test_perl_additional_dependencies"
|
2022-04-04 19:28:00 +00:00
|
|
|
"test_r_hook"
|
2023-02-09 02:58:07 +00:00
|
|
|
"test_r_inline"
|
2022-04-04 19:28:00 +00:00
|
|
|
"test_r_inline_hook"
|
|
|
|
"test_r_local_with_additional_dependencies_hook"
|
|
|
|
"test_r_with_additional_dependencies_hook"
|
|
|
|
"test_run_a_node_hook_default_version"
|
2023-02-09 02:58:07 +00:00
|
|
|
"test_run_lib_additional_dependencies"
|
2022-04-04 19:28:00 +00:00
|
|
|
"test_run_versioned_node_hook"
|
2023-02-09 02:58:07 +00:00
|
|
|
"test_rust_cli_additional_dependencies"
|
|
|
|
"test_swift_language"
|
2023-12-10 02:42:33 +00:00
|
|
|
"test_run_example_executable"
|
|
|
|
"test_run_dep"
|
2022-04-04 19:28:00 +00:00
|
|
|
|
|
|
|
# i don't know why these fail
|
|
|
|
"test_install_existing_hooks_no_overwrite"
|
|
|
|
"test_installed_from_venv"
|
|
|
|
"test_uninstall_restores_legacy_hooks"
|
2023-02-09 02:58:07 +00:00
|
|
|
"test_dotnet_"
|
2022-10-07 17:26:12 +00:00
|
|
|
|
|
|
|
# Expects `git commit` to fail when `pre-commit` is not in the `$PATH`,
|
|
|
|
# but we use an absolute path so it's not an issue.
|
|
|
|
"test_environment_not_sourced"
|
2024-04-09 08:29:57 +00:00
|
|
|
|
|
|
|
# Docker required
|
|
|
|
"test_docker_"
|
2022-04-04 19:28:00 +00:00
|
|
|
];
|
|
|
|
|
2021-12-01 10:57:53 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"pre_commit"
|
|
|
|
];
|
2021-06-10 10:19:28 +00:00
|
|
|
|
2023-02-09 02:58:07 +00:00
|
|
|
passthru.tests.version = testers.testVersion {
|
|
|
|
package = pre-commit;
|
|
|
|
};
|
|
|
|
|
2019-08-09 19:24:08 +00:00
|
|
|
meta = with lib; {
|
2018-07-30 23:19:24 +00:00
|
|
|
description = "Framework for managing and maintaining multi-language pre-commit hooks";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://pre-commit.com/";
|
2018-07-30 23:19:24 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ borisbabic ];
|
2023-11-27 01:17:53 +00:00
|
|
|
mainProgram = "pre-commit";
|
2018-07-30 23:19:24 +00:00
|
|
|
};
|
|
|
|
}
|