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