nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchFromGitHub,
4 buildPythonPackage,
5 smbus-cffi,
6 urwid,
7}:
8
9buildPythonPackage rec {
10 pname = "pijuice";
11 version = "1.8";
12 format = "setuptools";
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 tag = "V${version}";
20 sha256 = "sha256-tPYuI+VzbxmTeY/L3s0oDoydRDXJ6t76KmLUyJzxUvU=";
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 = [
38 smbus-cffi
39 urwid
40 ];
41
42 # Remove the following files from the package:
43 #
44 # pijuice_cli - A precompiled ELF binary that is a setuid wrapper for calling
45 # pijuice_cli.py
46 #
47 # pijuiceboot - a precompiled ELF binary for flashing firmware. Not needed for
48 # the python library.
49 #
50 # pijuice_sys.py - A program that acts as a system daemon for monitoring the
51 # pijuice.
52 preFixup = ''
53 rm $out/bin/pijuice_cli
54 rm $out/bin/pijuice_sys.py
55 rm $out/bin/pijuiceboot
56 mv $out/bin/pijuice_cli.py $out/bin/pijuice_cli
57 '';
58
59 # no tests
60 doCheck = false;
61
62 meta = {
63 description = "Library and resources for PiJuice HAT for Raspberry Pi";
64 mainProgram = "pijuice_cli";
65 homepage = "https://github.com/PiSupply/PiJuice";
66 license = lib.licenses.gpl3Plus;
67 maintainers = with lib.maintainers; [ hexagonal-sun ];
68 };
69}