Made with
```shell
git restore .
fd '\.nix$' pkgs/ --type f -j1 -x bash -xc "$(cat <<"EOF"
typos --no-check-filenames --write-changes "$1"
git diff --exit-code "$1" && exit
#( git diff "$1" | grep -qE "^\+ +[^# ]") && git restore "$1"
count1="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> ' | wc -l )"
count2="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> (<span style="color:#f8f8f2;"> *</span>)?<span style="color:#75715e;">.*</span>$' | wc -l )"
[[ $count1 -ne $count2 ]] && git restore "$1"
EOF
)" -- {}
```
and filtered with `GIT_DIFF_OPTS='--unified=15' git -c interactive.singleKey=true add --patch`
I initially tried using the tree-sitter cli, python bindings and even ast-grep through various means, but this is what I ended up with.
64 lines
1.4 KiB
Nix
64 lines
1.4 KiB
Nix
{
|
|
lib,
|
|
buildPythonPackage,
|
|
fetchFromGitHub,
|
|
setuptools,
|
|
isPyPy,
|
|
# nativeCheckInputs
|
|
pytest,
|
|
pytest-xdist,
|
|
# optional dependencies
|
|
pycryptodome,
|
|
safe-pysha3,
|
|
}:
|
|
|
|
buildPythonPackage rec {
|
|
pname = "eth-hash";
|
|
version = "0.7.1";
|
|
pyproject = true;
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "ethereum";
|
|
repo = "eth-hash";
|
|
tag = "v${version}";
|
|
hash = "sha256-91jWZDqrd7ZZlM0D/3sDokJ26NiAQ3gdeBebTV1Lq8s=";
|
|
};
|
|
|
|
build-system = [ setuptools ];
|
|
|
|
nativeCheckInputs =
|
|
[
|
|
pytest
|
|
pytest-xdist
|
|
]
|
|
++ optional-dependencies.pycryptodome
|
|
# safe-pysha3 is not available on pypy
|
|
++ lib.optional (!isPyPy) optional-dependencies.pysha3;
|
|
|
|
# Backends need to be tested separately and can not use hook
|
|
checkPhase =
|
|
''
|
|
runHook preCheck
|
|
pytest tests/core tests/backends/pycryptodome
|
|
''
|
|
+ lib.optionalString (!isPyPy) ''
|
|
pytest tests/backends/pysha3
|
|
''
|
|
+ ''
|
|
runHook postCheck
|
|
'';
|
|
|
|
optional-dependencies = {
|
|
pycryptodome = [ pycryptodome ];
|
|
pysha3 = [ safe-pysha3 ];
|
|
};
|
|
|
|
meta = {
|
|
description = "Ethereum hashing function keccak256";
|
|
homepage = "https://github.com/ethereum/eth-hash";
|
|
changelog = "https://github.com/ethereum/eth-hash/blob/v${version}/docs/release_notes.rst";
|
|
license = lib.licenses.mit;
|
|
maintainers = with lib.maintainers; [ hellwolf ];
|
|
};
|
|
}
|