at 24.11-pre 5.0 kB view raw
1{ lib 2, fetchFromGitHub 3, python3Packages 4, libiconv 5, cargo 6, coursier 7, dotnet-sdk 8, git 9, glibcLocales 10, go 11, nodejs 12, perl 13, cabal-install 14, testers 15, pre-commit 16}: 17 18with python3Packages; 19buildPythonApplication rec { 20 pname = "pre-commit"; 21 version = "3.7.1"; 22 format = "setuptools"; 23 24 disabled = pythonOlder "3.9"; 25 26 src = fetchFromGitHub { 27 owner = "pre-commit"; 28 repo = "pre-commit"; 29 rev = "refs/tags/v${version}"; 30 hash = "sha256-+9NNXM4i6saxktF1pl93dmkrqjsErqMB6kEK3IPQTNQ="; 31 }; 32 33 patches = [ 34 ./languages-use-the-hardcoded-path-to-python-binaries.patch 35 ./hook-tmpl.patch 36 ./pygrep-pythonpath.patch 37 ]; 38 39 propagatedBuildInputs = [ 40 cfgv 41 identify 42 nodeenv 43 pyyaml 44 toml 45 virtualenv 46 ]; 47 48 nativeCheckInputs = [ 49 cargo 50 coursier 51 dotnet-sdk 52 git 53 glibcLocales 54 go 55 libiconv # For rust tests on Darwin 56 nodejs 57 perl 58 pytest-env 59 pytest-forked 60 pytest-xdist 61 pytestCheckHook 62 re-assert 63 cabal-install 64 ]; 65 66 # i686-linux: dotnet-sdk not available 67 doCheck = stdenv.buildPlatform.system != "i686-linux"; 68 69 postPatch = '' 70 substituteInPlace pre_commit/resources/hook-tmpl \ 71 --subst-var-by pre-commit $out 72 substituteInPlace pre_commit/languages/python.py \ 73 --subst-var-by virtualenv ${virtualenv} 74 substituteInPlace pre_commit/languages/node.py \ 75 --subst-var-by nodeenv ${nodeenv} 76 77 patchShebangs pre_commit/resources/hook-tmpl 78 ''; 79 80 pytestFlagsArray = [ 81 "--forked" 82 ]; 83 84 preCheck = lib.optionalString (!(stdenv.isLinux && stdenv.isAarch64)) '' 85 # Disable outline atomics for rust tests on aarch64-linux. 86 export RUSTFLAGS="-Ctarget-feature=-outline-atomics" 87 '' + '' 88 export GIT_AUTHOR_NAME=test GIT_COMMITTER_NAME=test \ 89 GIT_AUTHOR_EMAIL=test@example.com GIT_COMMITTER_EMAIL=test@example.com \ 90 VIRTUALENV_NO_DOWNLOAD=1 PRE_COMMIT_NO_CONCURRENCY=1 LANG=en_US.UTF-8 91 92 # Resolve `.NET location: Not found` errors for dotnet tests 93 export DOTNET_ROOT="${dotnet-sdk}" 94 95 export HOME=$(mktemp -d) 96 97 git init -b master 98 99 python -m venv --system-site-packages venv 100 source "$PWD/venv/bin/activate" 101 ''; 102 103 postCheck = '' 104 deactivate 105 ''; 106 107 # Propagating dependencies leaks them through $PYTHONPATH which causes issues 108 # when used in nix-shell. 109 postFixup = '' 110 rm $out/nix-support/propagated-build-inputs 111 ''; 112 113 disabledTests = [ 114 # ERROR: The install method you used for conda--probably either `pip install conda` 115 # or `easy_install conda`--is not compatible with using conda as an application. 116 "test_conda_" 117 "test_local_conda_" 118 119 # /build/pytest-of-nixbld/pytest-0/test_install_ruby_with_version0/rbenv-2.7.2/libexec/rbenv-init: 120 # /usr/bin/env: bad interpreter: No such file or directory 121 "test_ruby_" 122 123 # network 124 "test_additional_dependencies_roll_forward" 125 "test_additional_golang_dependencies_installed" 126 "test_additional_node_dependencies_installed" 127 "test_additional_rust_cli_dependencies_installed" 128 "test_additional_rust_lib_dependencies_installed" 129 "test_coursier_hook" 130 "test_coursier_hook_additional_dependencies" 131 "test_dart" 132 "test_dart_additional_deps" 133 "test_dart_additional_deps_versioned" 134 "test_during_commit_all" 135 "test_golang_default_version" 136 "test_golang_hook" 137 "test_golang_hook_still_works_when_gobin_is_set" 138 "test_golang_infer_go_version_default" 139 "test_golang_system" 140 "test_golang_versioned" 141 "test_language_version_with_rustup" 142 "test_installs_rust_missing_rustup" 143 "test_installs_without_links_outside_env" 144 "test_local_golang_additional_deps" 145 "test_lua" 146 "test_lua_additional_dependencies" 147 "test_node_additional_deps" 148 "test_node_hook_versions" 149 "test_perl_additional_dependencies" 150 "test_r_hook" 151 "test_r_inline" 152 "test_r_inline_hook" 153 "test_r_local_with_additional_dependencies_hook" 154 "test_r_with_additional_dependencies_hook" 155 "test_run_a_node_hook_default_version" 156 "test_run_lib_additional_dependencies" 157 "test_run_versioned_node_hook" 158 "test_rust_cli_additional_dependencies" 159 "test_swift_language" 160 "test_run_example_executable" 161 "test_run_dep" 162 163 # i don't know why these fail 164 "test_install_existing_hooks_no_overwrite" 165 "test_installed_from_venv" 166 "test_uninstall_restores_legacy_hooks" 167 "test_dotnet_" 168 169 # Expects `git commit` to fail when `pre-commit` is not in the `$PATH`, 170 # but we use an absolute path so it's not an issue. 171 "test_environment_not_sourced" 172 173 # Docker required 174 "test_docker_" 175 ]; 176 177 pythonImportsCheck = [ 178 "pre_commit" 179 ]; 180 181 passthru.tests.version = testers.testVersion { 182 package = pre-commit; 183 }; 184 185 meta = with lib; { 186 description = "A framework for managing and maintaining multi-language pre-commit hooks"; 187 homepage = "https://pre-commit.com/"; 188 license = licenses.mit; 189 maintainers = with maintainers; [ borisbabic ]; 190 mainProgram = "pre-commit"; 191 }; 192}