1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonAtLeast,
6 pythonOlder,
7 fetchFromGitHub,
8 replaceVars,
9 ffmpeg,
10 libopus,
11 aiohttp,
12 aiodns,
13 audioop-lts,
14 brotli,
15 orjson,
16 poetry-core,
17 poetry-dynamic-versioning,
18 pynacl,
19 typing-extensions,
20}:
21
22buildPythonPackage rec {
23 pname = "nextcord";
24 version = "3.1.0";
25 pyproject = true;
26
27 disabled = pythonOlder "3.12";
28
29 src = fetchFromGitHub {
30 owner = "nextcord";
31 repo = "nextcord";
32 tag = "v${version}";
33 hash = "sha256-E8vRKH2Xgva7W5qW9kJBWzVfCuSiRyoAyO72mcGvkpg=";
34 };
35
36 patches = [
37 (replaceVars ./paths.patch {
38 ffmpeg = "${ffmpeg}/bin/ffmpeg";
39 libopus = "${libopus}/lib/libopus${stdenv.hostPlatform.extensions.sharedLibrary}";
40 })
41 ];
42
43 postPatch = ''
44 # disable dynamic versioning
45 substituteInPlace pyproject.toml \
46 --replace-fail 'version = "0.0.0"' 'version = "${version}"' \
47 --replace-fail 'enable = true' 'enable = false'
48 '';
49
50 build-system = [
51 poetry-core
52 poetry-dynamic-versioning
53 ];
54
55 dependencies =
56 [
57 aiodns
58 aiohttp
59 brotli
60 orjson
61 pynacl
62 typing-extensions
63 ]
64 ++ lib.optionals (pythonAtLeast "3.13") [
65 audioop-lts
66 ];
67
68 # upstream has no tests
69 doCheck = false;
70
71 pythonImportsCheck = [
72 "nextcord"
73 "nextcord.ext.commands"
74 "nextcord.ext.tasks"
75 ];
76
77 meta = with lib; {
78 changelog = "https://github.com/nextcord/nextcord/blob/${src.tag}/docs/whats_new.rst";
79 description = "Python wrapper for the Discord API forked from discord.py";
80 homepage = "https://github.com/nextcord/nextcord";
81 license = licenses.mit;
82 maintainers = with maintainers; [ dotlambda ];
83 };
84}