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.
58 lines
1001 B
Nix
58 lines
1001 B
Nix
{
|
|
lib,
|
|
buildPythonPackage,
|
|
fetchFromGitHub,
|
|
|
|
# build-system
|
|
setuptools,
|
|
|
|
# dependencies
|
|
itsdangerous,
|
|
python-multipart,
|
|
|
|
# tests
|
|
asgi-lifespan,
|
|
pytestCheckHook,
|
|
starlette,
|
|
httpx,
|
|
pytest-asyncio,
|
|
}:
|
|
|
|
buildPythonPackage rec {
|
|
pname = "asgi-csrf";
|
|
version = "0.11";
|
|
pyproject = true;
|
|
|
|
# PyPI tarball doesn't include tests directory
|
|
src = fetchFromGitHub {
|
|
owner = "simonw";
|
|
repo = "asgi-csrf";
|
|
tag = version;
|
|
hash = "sha256-STitMWabAPz61AU+5gFJSHBBqf67Q8UtS6ks8Q/ZybY=";
|
|
};
|
|
|
|
build-system = [ setuptools ];
|
|
|
|
dependencies = [
|
|
itsdangerous
|
|
python-multipart
|
|
];
|
|
|
|
nativeCheckInputs = [
|
|
asgi-lifespan
|
|
httpx
|
|
pytest-asyncio
|
|
pytestCheckHook
|
|
starlette
|
|
];
|
|
|
|
pythonImportsCheck = [ "asgi_csrf" ];
|
|
|
|
meta = with lib; {
|
|
description = "ASGI middleware for protecting against CSRF attacks";
|
|
license = licenses.asl20;
|
|
homepage = "https://github.com/simonw/asgi-csrf";
|
|
maintainers = [ maintainers.ris ];
|
|
};
|
|
}
|