git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #154773 from hexagonal-sun/add-pijuice

pijuice: init at 1.7

commit43582dcd07e29cd6e26704b012e0b890c9498c0c authorAnderson Torres <torres.anderson.85@protonmail.com> dateThu 13 Jan 2022, 18:35 (5 years ago) parent40c7f695d888bf
4 files changed+74
pkgs/development/python-modules/pijuice/default.nix+61 pkgs/development/python-modules/pijuice/patch-shebang.diff+9 pkgs/top-level/all-packages.nix+2 pkgs/top-level/python-packages.nix+2
pkgs/development/python-modules/pijuice/default.nixnew file+61
@@ -0,0 +1,61 @@
1+{ lib
2+, fetchFromGitHub
3+, buildPythonPackage
4+, pythonOlder
5+, smbus-cffi
6+, urwid
7+}:
8+
9+buildPythonPackage rec {
10+ pname = "pijuice";
11+ version = "1.7";
12+ disabled = pythonOlder "3.6";
13+
14+ src = fetchFromGitHub {
15+ owner = "PiSupply";
16+ repo = "PiJuice";
17+ # rev hash retrieved from the latest modification on file Software/Source/VERSION, as this project
18+ # does not use Github tags facility
19+ rev = "3ba6719ab614a3dc7495d5d9c900dd4ea977c7e3";
20+ sha256 = "GoNN07YgVaktpeY5iYDbfpy5fxkU1x0V3Sb1hgGAQt4=";
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+
32+ preBuild = ''
33+ cd Software/Source
34+ '';
35+
36+ propagatedBuildInputs = [ smbus-cffi urwid ];
37+
38+ # Remove the following files from the package:
39+ #
40+ # pijuice_cli - A precompiled ELF binary that is a setuid wrapper for calling
41+ # pijuice_cli.py
42+ #
43+ # pijuiceboot - a precompiled ELF binary for flashing firmware. Not needed for
44+ # the python library.
45+ #
46+ # pijuice_sys.py - A program that acts as a system daemon for monitoring the
47+ # pijuice.
48+ preFixup = ''
49+ rm $out/bin/pijuice_cli
50+ rm $out/bin/pijuice_sys.py
51+ rm $out/bin/pijuiceboot
52+ mv $out/bin/pijuice_cli.py $out/bin/pijuice_cli
53+ '';
54+
55+ meta = with lib; {
56+ description = "Library and resources for PiJuice HAT for Raspberry Pi";
57+ homepage = "https://github.com/PiSupply/PiJuice";
58+ license = licenses.gpl3Plus;
59+ maintainers = with maintainers; [ hexagonal-sun ];
60+ };
61+}
pkgs/development/python-modules/pijuice/patch-shebang.diffnew file+9
@@ -0,0 +1,9 @@
1+diff --git a/Software/Source/src/pijuice_cli.py b/Software/Source/src/pijuice_cli.py
2+index c366fee..37af383 100644
3+--- a/Software/Source/src/pijuice_cli.py
4++++ b/Software/Source/src/pijuice_cli.py
5+@@ -1,3 +1,4 @@
6++#!/usr/bin/python3
7+ # This python script to be executed as user pijuice by the setuid program pijuice_cli
8+ # Python 3 only
9+ #
pkgs/top-level/all-packages.nix+2
@@ -27464,6 +27464,8 @@ with pkgs;
2746427464
2746527465 pijul = callPackage ../applications/version-management/pijul { };
2746627466
27467+ pijuice = with python3Packages; toPythonApplication pijuice;
27468+
2746727469 ping = callPackage ../applications/networking/ping { };
2746827470
2746927471 piper = callPackage ../os-specific/linux/piper { };
pkgs/top-level/python-packages.nix+2
@@ -5953,6 +5953,8 @@ in {
59535953
59545954 piexif = callPackage ../development/python-modules/piexif { };
59555955
5956+ pijuice = callPackage ../development/python-modules/pijuice { };
5957+
59565958 pika = callPackage ../development/python-modules/pika { };
59575959
59585960 pika-pool = callPackage ../development/python-modules/pika-pool { };