1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pytestCheckHook,
6 pythonOlder,
7 aiohttp,
8 attrs,
9 multidict,
10 colorlog,
11 pynacl,
12 pytest-cov-stub,
13 pytest-randomly,
14 pytest-asyncio,
15 mock,
16}:
17buildPythonPackage rec {
18 pname = "hikari";
19 version = "2.1.0";
20
21 src = fetchFromGitHub {
22 owner = "hikari-py";
23 repo = "hikari";
24 tag = version;
25 hash = "sha256-/A3D3nG1lSCQU92dM+6YroxWlGKrv47ntkZaJZTAJUA=";
26 # The git commit is part of the `hikari.__git_sha1__` original output;
27 # leave that output the same in nixpkgs. Use the `.git` directory
28 # to retrieve the commit SHA, and remove the directory afterwards,
29 # since it is not needed after that.
30 leaveDotGit = true;
31 postFetch = ''
32 cd "$out"
33 git rev-parse HEAD > $out/COMMIT
34 find "$out" -name .git -print0 | xargs -0 rm -rf
35 '';
36 };
37
38 propagatedBuildInputs = [
39 aiohttp
40 attrs
41 multidict
42 colorlog
43 ];
44
45 pythonRelaxDeps = true;
46
47 optional-dependencies = {
48 server = [ pynacl ];
49 };
50
51 nativeCheckInputs = [
52 pytestCheckHook
53 pytest-asyncio
54 pytest-cov-stub
55 pytest-randomly
56 mock
57 ];
58
59 pythonImportsCheck = [ "hikari" ];
60
61 disabled = pythonOlder "3.7";
62
63 postPatch = ''
64 substituteInPlace hikari/_about.py \
65 --replace-fail "__git_sha1__: typing.Final[str] = \"HEAD\"" "__git_sha1__: typing.Final[str] = \"$(cat $src/COMMIT)\""
66 # XXX: Remove once pytest-asyncio is updated to 0.24+
67 substituteInPlace pyproject.toml \
68 --replace-fail "asyncio_default_fixture_loop_scope = \"func\"" ""
69 '';
70
71 meta = {
72 description = "Discord API wrapper for Python written with asyncio";
73 homepage = "https://www.hikari-py.dev/";
74 changelog = "https://github.com/hikari-py/hikari/releases/tag/${version}";
75 license = lib.licenses.mit;
76 maintainers = with lib.maintainers; [
77 tomodachi94
78 sigmanificient
79 ];
80 };
81}