diff --git a/pkgs/by-name/pr/pre-commit/package.nix b/pkgs/by-name/pr/pre-commit/package.nix index 517f6fc3ef85..c5c62a54499f 100644 --- a/pkgs/by-name/pr/pre-commit/package.nix +++ b/pkgs/by-name/pr/pre-commit/package.nix @@ -107,12 +107,6 @@ buildPythonApplication rec { deactivate ''; - # Propagating dependencies leaks them through $PYTHONPATH which causes issues - # when used in nix-shell. - postFixup = '' - rm $out/nix-support/propagated-build-inputs - ''; - 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. @@ -182,8 +176,8 @@ buildPythonApplication rec { "pre_commit" ]; - passthru.tests.version = testers.testVersion { - package = pre-commit; + passthru.tests = callPackage ./tests.nix { + inherit git pre-commit; }; meta = with lib; { diff --git a/pkgs/by-name/pr/pre-commit/tests.nix b/pkgs/by-name/pr/pre-commit/tests.nix new file mode 100644 index 000000000000..a1b40bc2d8cc --- /dev/null +++ b/pkgs/by-name/pr/pre-commit/tests.nix @@ -0,0 +1,45 @@ +{ + git, + pre-commit, + runCommand, + testers, +}: +{ + check-meta-hooks = + runCommand "check-meta-hooks" + { + nativeBuildInputs = [ + git + pre-commit + ]; + } + '' + cd "$(mktemp --directory)" + export HOME="$PWD" + cat << 'EOF' > .pre-commit-config.yaml + repos: + - repo: local + hooks: + - id: echo + name: echo + entry: echo + files: \.yaml$ + language: system + - repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes + - id: identity + EOF + git config --global user.email "you@example.com" + git config --global user.name "Your Name" + git init --initial-branch=main + git add . + pre-commit run --all-files + touch $out + ''; + + version = testers.testVersion { + package = pre-commit; + }; +}