1{
2 lib,
3 fetchFromGitHub,
4 buildPythonPackage,
5
6 # build-system
7 setuptools,
8
9 # dependencies
10 amaranth,
11 apollo-fpga,
12 libusb1,
13 luna-soc,
14 luna-usb,
15 prompt-toolkit,
16 pyfwup,
17 pygreat,
18 pyserial,
19 pyusb,
20 tabulate,
21 tomli,
22 tqdm,
23
24 # tests
25 pytestCheckHook,
26 udevCheckHook,
27}:
28buildPythonPackage rec {
29 pname = "cynthion";
30 version = "0.2.4";
31 pyproject = true;
32
33 src = fetchFromGitHub {
34 owner = "greatscottgadgets";
35 repo = "cynthion";
36 tag = version;
37 hash = "sha256-ebd2L7o6GO57TpwJ7+MOhVSb+I/E8kD7d7DqPj4B3FM=";
38 };
39
40 sourceRoot = "${src.name}/cynthion/python";
41
42 postPatch = ''
43 substituteInPlace pyproject.toml \
44 --replace-fail '"setuptools-git-versioning<2"' "" \
45 --replace-fail 'dynamic = ["version"]' 'version = "${version}"'
46 '';
47
48 nativeBuildInputs = [ udevCheckHook ];
49
50 build-system = [
51 setuptools
52 ];
53
54 pythonRemoveDeps = [ "future" ];
55
56 dependencies = [
57 amaranth
58 apollo-fpga
59 libusb1
60 luna-soc
61 luna-usb
62 prompt-toolkit
63 pyfwup
64 pygreat
65 pyserial
66 pyusb
67 tabulate
68 tomli
69 tqdm
70 ];
71
72 nativeCheckInputs = [
73 pytestCheckHook
74 ];
75
76 pythonImportsCheck = [ "cynthion" ];
77
78 # Make udev rules available for NixOS option services.udev.packages
79 postInstall = ''
80 install -Dm444 \
81 -t $out/lib/udev/rules.d \
82 build/lib/cynthion/assets/54-cynthion.rules
83 '';
84
85 meta = {
86 description = "Python package and utilities for the Great Scott Gadgets Cynthion USB Test Instrument";
87 homepage = "https://github.com/greatscottgadgets/cynthion";
88 changelog = "https://github.com/greatscottgadgets/cynthion/releases/tag/${src.tag}";
89 license = lib.licenses.bsd3;
90 maintainers = with lib.maintainers; [ carlossless ];
91 };
92}