···11+{ lib
22+, fetchFromGitHub
33+, buildPythonPackage
44+, pythonOlder
55+, smbus-cffi
66+, urwid
77+}:
88+99+buildPythonPackage rec {
1010+ pname = "pijuice";
1111+ version = "1.7";
1212+ disabled = pythonOlder "3.6";
1313+1414+ src = fetchFromGitHub {
1515+ owner = "PiSupply";
1616+ repo = "PiJuice";
1717+ # rev hash retrieved from the latest modification on file Software/Source/VERSION, as this project
1818+ # does not use Github tags facility
1919+ rev = "3ba6719ab614a3dc7495d5d9c900dd4ea977c7e3";
2020+ sha256 = "GoNN07YgVaktpeY5iYDbfpy5fxkU1x0V3Sb1hgGAQt4=";
2121+ };
2222+2323+ patches = [
2424+ # The pijuice_cli.cli file doesn't have a shebang as the first line of the
2525+ # script. Without it, the pythonWrapPrograms hook will not wrap the program.
2626+ # Add a python shebang here so that the the hook is triggered.
2727+ ./patch-shebang.diff
2828+ ];
2929+3030+ PIJUICE_BUILD_BASE = 1;
3131+3232+ preBuild = ''
3333+ cd Software/Source
3434+ '';
3535+3636+ propagatedBuildInputs = [ smbus-cffi urwid ];
3737+3838+ # Remove the following files from the package:
3939+ #
4040+ # pijuice_cli - A precompiled ELF binary that is a setuid wrapper for calling
4141+ # pijuice_cli.py
4242+ #
4343+ # pijuiceboot - a precompiled ELF binary for flashing firmware. Not needed for
4444+ # the python library.
4545+ #
4646+ # pijuice_sys.py - A program that acts as a system daemon for monitoring the
4747+ # pijuice.
4848+ preFixup = ''
4949+ rm $out/bin/pijuice_cli
5050+ rm $out/bin/pijuice_sys.py
5151+ rm $out/bin/pijuiceboot
5252+ mv $out/bin/pijuice_cli.py $out/bin/pijuice_cli
5353+ '';
5454+5555+ meta = with lib; {
5656+ description = "Library and resources for PiJuice HAT for Raspberry Pi";
5757+ homepage = "https://github.com/PiSupply/PiJuice";
5858+ license = licenses.gpl3Plus;
5959+ maintainers = with maintainers; [ hexagonal-sun ];
6060+ };
6161+}
···11+diff --git a/Software/Source/src/pijuice_cli.py b/Software/Source/src/pijuice_cli.py
22+index c366fee..37af383 100644
33+--- a/Software/Source/src/pijuice_cli.py
44++++ b/Software/Source/src/pijuice_cli.py
55+@@ -1,3 +1,4 @@
66++#!/usr/bin/python3
77+ # This python script to be executed as user pijuice by the setuid program pijuice_cli
88+ # Python 3 only
99+ #