1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 buildPythonPackage,
6 cryptography,
7 click,
8 construct,
9 ecdsa,
10 hidapi,
11 intelhex,
12 pillow,
13 protobuf,
14 requests,
15 setuptools,
16 setuptools-scm,
17 tabulate,
18 toml,
19 AppKit,
20}:
21
22buildPythonPackage rec {
23 pname = "ledgerwallet";
24 version = "0.5.0";
25 format = "pyproject";
26
27 src = fetchFromGitHub {
28 owner = "LedgerHQ";
29 repo = "ledgerctl";
30 rev = "v${version}";
31 hash = "sha256-PBULYvyO3+YaW+a1/enJtKB/DR4ndL/o/WdpETbWyZ0=";
32 };
33
34 buildInputs = [
35 setuptools
36 setuptools-scm
37 ] ++ lib.optionals stdenv.isDarwin [ AppKit ];
38 propagatedBuildInputs = [
39 cryptography
40 click
41 construct
42 ecdsa
43 hidapi
44 intelhex
45 pillow
46 protobuf
47 requests
48 tabulate
49 toml
50 ];
51
52 postPatch = ''
53 substituteInPlace pyproject.toml \
54 --replace-fail '"protobuf >=3.20,<4"' '"protobuf >=3.20"'
55 '';
56
57 # Regenerate protobuf bindings to lift the version upper-bound and enable
58 # compatibility the current default protobuf library.
59 preBuild = ''
60 protoc --python_out=. --pyi_out=. ledgerwallet/proto/*.proto
61 '';
62
63 pythonImportsCheck = [ "ledgerwallet" ];
64
65 meta = with lib; {
66 homepage = "https://github.com/LedgerHQ/ledgerctl";
67 description = "Library to control Ledger devices";
68 mainProgram = "ledgerctl";
69 license = licenses.mit;
70 maintainers = with maintainers; [
71 d-xo
72 erdnaxe
73 ];
74 };
75}