Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 216 lines 6.3 kB view raw
1{ 2 lib, 3 fetchFromGitHub, 4 python3Packages, 5 libiconv, 6 cargo, 7 coursier, 8 dotnet-sdk, 9 gitMinimal, 10 go, 11 nodejs, 12 perl, 13 cabal-install, 14 pre-commit, 15}: 16 17with python3Packages; 18let 19 i686Linux = stdenv.buildPlatform.system == "i686-linux"; 20in 21buildPythonApplication rec { 22 pname = "pre-commit"; 23 version = "4.0.1"; 24 format = "setuptools"; 25 26 disabled = pythonOlder "3.9"; 27 28 src = fetchFromGitHub { 29 owner = "pre-commit"; 30 repo = "pre-commit"; 31 tag = "v${version}"; 32 hash = "sha256-qMNnzAxJOS7mabHmGYZ/VkDrpaZbqTJyETSCxq/OrGQ="; 33 }; 34 35 patches = [ 36 ./languages-use-the-hardcoded-path-to-python-binaries.patch 37 ./hook-tmpl.patch 38 ./pygrep-pythonpath.patch 39 ]; 40 41 propagatedBuildInputs = [ 42 cfgv 43 identify 44 nodeenv 45 pyyaml 46 toml 47 virtualenv 48 ]; 49 50 nativeCheckInputs = 51 [ 52 cargo 53 gitMinimal 54 go 55 libiconv # For rust tests on Darwin 56 perl 57 pytest-env 58 pytest-forked 59 pytest-xdist 60 pytestCheckHook 61 re-assert 62 cabal-install 63 ] 64 ++ lib.optionals (!i686Linux) [ 65 # coursier can be moved back to the main nativeCheckInputs list once we’re able to bootstrap a 66 # JRE on i686-linux: <https://github.com/NixOS/nixpkgs/issues/314873>. When coursier gets 67 # moved back to the main nativeCheckInputs list, don’t forget to re-enable the 68 # coursier-related test that is currently disabled on i686-linux. 69 coursier 70 # i686-linux: dotnet-sdk not available 71 dotnet-sdk 72 # nodejs can be moved back to the main nativeCheckInputs list once this 73 # issue is fixed: <https://github.com/NixOS/nixpkgs/issues/387658>. When nodejs gets 74 # moved back to the main nativeCheckInputs list, don’t forget to re-enable the 75 # Node.js-related tests that are currently disabled on i686-linux. 76 nodejs 77 ]; 78 79 postPatch = '' 80 substituteInPlace pre_commit/resources/hook-tmpl \ 81 --subst-var-by pre-commit $out 82 substituteInPlace pre_commit/languages/python.py \ 83 --subst-var-by virtualenv ${virtualenv} 84 substituteInPlace pre_commit/languages/node.py \ 85 --subst-var-by nodeenv ${nodeenv} 86 87 patchShebangs pre_commit/resources/hook-tmpl 88 ''; 89 90 pytestFlagsArray = [ 91 "--forked" 92 ]; 93 94 preCheck = 95 lib.optionalString (!(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64)) '' 96 # Disable outline atomics for rust tests on aarch64-linux. 97 export RUSTFLAGS="-Ctarget-feature=-outline-atomics" 98 '' 99 + '' 100 export GIT_AUTHOR_NAME=test GIT_COMMITTER_NAME=test \ 101 GIT_AUTHOR_EMAIL=test@example.com GIT_COMMITTER_EMAIL=test@example.com \ 102 VIRTUALENV_NO_DOWNLOAD=1 PRE_COMMIT_NO_CONCURRENCY=1 103 '' 104 + lib.optionalString (!i686Linux) '' 105 # Resolve `.NET location: Not found` errors for dotnet tests 106 export DOTNET_ROOT="${dotnet-sdk}/share/dotnet" 107 '' 108 + '' 109 export HOME=$(mktemp -d) 110 111 git init -b master 112 113 python -m venv --system-site-packages venv 114 source "$PWD/venv/bin/activate" 115 ''; 116 117 postCheck = '' 118 deactivate 119 ''; 120 121 disabledTests = 122 [ 123 # ERROR: The install method you used for conda--probably either `pip install conda` 124 # or `easy_install conda`--is not compatible with using conda as an application. 125 "test_conda_" 126 "test_local_conda_" 127 128 # /build/pytest-of-nixbld/pytest-0/test_install_ruby_with_version0/rbenv-2.7.2/libexec/rbenv-init: 129 # /usr/bin/env: bad interpreter: No such file or directory 130 "test_ruby_" 131 132 # network 133 "test_additional_dependencies_roll_forward" 134 "test_additional_golang_dependencies_installed" 135 "test_additional_node_dependencies_installed" 136 "test_additional_rust_cli_dependencies_installed" 137 "test_additional_rust_lib_dependencies_installed" 138 "test_coursier_hook" 139 "test_coursier_hook_additional_dependencies" 140 "test_dart" 141 "test_dart_additional_deps" 142 "test_dart_additional_deps_versioned" 143 "test_during_commit_all" 144 "test_golang_default_version" 145 "test_golang_hook" 146 "test_golang_hook_still_works_when_gobin_is_set" 147 "test_golang_infer_go_version_default" 148 "test_golang_system" 149 "test_golang_versioned" 150 "test_language_version_with_rustup" 151 "test_installs_rust_missing_rustup" 152 "test_installs_without_links_outside_env" 153 "test_local_golang_additional_deps" 154 "test_lua" 155 "test_lua_additional_dependencies" 156 "test_node_additional_deps" 157 "test_node_hook_versions" 158 "test_perl_additional_dependencies" 159 "test_r_hook" 160 "test_r_inline" 161 "test_r_inline_hook" 162 "test_r_local_with_additional_dependencies_hook" 163 "test_r_with_additional_dependencies_hook" 164 "test_run_a_node_hook_default_version" 165 "test_run_lib_additional_dependencies" 166 "test_run_versioned_node_hook" 167 "test_rust_cli_additional_dependencies" 168 "test_swift_language" 169 "test_run_example_executable" 170 "test_run_dep" 171 172 # i don't know why these fail 173 "test_install_existing_hooks_no_overwrite" 174 "test_installed_from_venv" 175 "test_uninstall_restores_legacy_hooks" 176 "test_dotnet_" 177 "test_health_check_" 178 179 # Expects `git commit` to fail when `pre-commit` is not in the `$PATH`, 180 # but we use an absolute path so it's not an issue. 181 "test_environment_not_sourced" 182 183 # Docker required 184 "test_docker_" 185 ] 186 ++ lib.optionals i686Linux [ 187 # From coursier_test.py: 188 "test_error_if_no_deps_or_channel" 189 # From node_test.py: 190 "test_healthy_system_node" 191 "test_unhealthy_if_system_node_goes_missing" 192 "test_node_hook_system" 193 "test_node_with_user_config_set" 194 ]; 195 196 pythonImportsCheck = [ 197 "pre_commit" 198 ]; 199 200 # add gitMinimal as fallback, if git is not installed 201 preFixup = '' 202 makeWrapperArgs+=(--suffix PATH : ${lib.makeBinPath [ gitMinimal ]}) 203 ''; 204 205 passthru.tests = callPackage ./tests.nix { 206 inherit gitMinimal pre-commit; 207 }; 208 209 meta = with lib; { 210 description = "Framework for managing and maintaining multi-language pre-commit hooks"; 211 homepage = "https://pre-commit.com/"; 212 license = licenses.mit; 213 maintainers = with maintainers; [ borisbabic ]; 214 mainProgram = "pre-commit"; 215 }; 216}