1{ lib
2, fetchFromGitHub
3, buildPythonPackage
4, pythonOlder
5, smbus-cffi
6, urwid
7}:
8
9buildPythonPackage rec {
10 pname = "pijuice";
11 version = "1.7";
12 disabled = pythonOlder "3.6";
13
14 src = fetchFromGitHub {
15 owner = "PiSupply";
16 repo = "PiJuice";
17 # Latest commit that fixes using the library against python 3.9 by renaming
18 # isAlive() to is_alive(). The former function was removed in python 3.9.
19 rev = "e2dca1f8dcfa12e009952a882c0674a545d193d6";
20 sha256 = "07Jr7RSjqI8j0tT0MNAjrN1sjF1+mI+V0vtKInvtxj8=";
21 };
22
23 patches = [
24 # The pijuice_cli.cli file doesn't have a shebang as the first line of the
25 # script. Without it, the pythonWrapPrograms hook will not wrap the program.
26 # Add a python shebang here so that the the hook is triggered.
27 ./patch-shebang.diff
28 ];
29
30 PIJUICE_BUILD_BASE = 1;
31 PIJUICE_VERSION = version;
32
33 preBuild = ''
34 cd Software/Source
35 '';
36
37 propagatedBuildInputs = [ smbus-cffi urwid ];
38
39 # Remove the following files from the package:
40 #
41 # pijuice_cli - A precompiled ELF binary that is a setuid wrapper for calling
42 # pijuice_cli.py
43 #
44 # pijuiceboot - a precompiled ELF binary for flashing firmware. Not needed for
45 # the python library.
46 #
47 # pijuice_sys.py - A program that acts as a system daemon for monitoring the
48 # pijuice.
49 preFixup = ''
50 rm $out/bin/pijuice_cli
51 rm $out/bin/pijuice_sys.py
52 rm $out/bin/pijuiceboot
53 mv $out/bin/pijuice_cli.py $out/bin/pijuice_cli
54 '';
55
56 # no tests
57 doCheck = false;
58
59 meta = with lib; {
60 description = "Library and resources for PiJuice HAT for Raspberry Pi";
61 homepage = "https://github.com/PiSupply/PiJuice";
62 license = licenses.gpl3Plus;
63 maintainers = with maintainers; [ hexagonal-sun ];
64 };
65}