feat(bbuddy): evdev barcode scanner client

This commit is contained in:
arcnmx 2024-05-17 13:29:59 -07:00
parent c3cd9b0564
commit 90901a302c
24 changed files with 847 additions and 253 deletions

View file

@ -0,0 +1,37 @@
{
stdenvNoCC,
fetchFromGitHub,
lib,
...
}: let
inherit (lib.strings) removePrefix;
inherit (lib.trivial) importJSON;
lock = importJSON ../../flake.lock;
inherit (lock.nodes) barcodebuddy;
in
stdenvNoCC.mkDerivation {
pname = "barcodebuddy";
version = removePrefix "v" barcodebuddy.original.ref;
src = fetchFromGitHub {
inherit (barcodebuddy.locked) repo owner rev;
sha256 = barcodebuddy.locked.narHash;
};
skipConfigure = true;
skipBuild = true;
installPhase = ''
runHook preInstall
install -d $out
cp -ar api/ incl/ locales/ menu/ plugins/ *.php $out/
runHook postInstall
'';
meta = {
homepage = "https://github.com/Forceu/barcodebuddy";
license = lib.licenses.agpl3Plus;
};
}

View file

@ -0,0 +1,47 @@
{
stdenvNoCC,
makeWrapper,
barcodebuddy,
barcodebuddy-scanner,
screen,
lib,
enableRequests ? true,
enablePhp ? false,
php,
python3,
...
}: let
inherit (lib.lists) optional optionals;
inherit (lib.strings) makeBinPath;
python = python3.withPackages (
p:
[p.evdev]
++ optional enableRequests p.requests
);
in
stdenvNoCC.mkDerivation {
pname = "barcodebuddy-scanner.py";
inherit (barcodebuddy) version src;
inherit (barcodebuddy-scanner) patches meta;
skipConfigure = true;
skipBuild = true;
nativeBuildInputs = [
makeWrapper
];
buildInputs = [python];
scannerPath = makeBinPath (
optionals enablePhp [screen php]
);
${
if enablePhp
then "barcodebuddyScript"
else null
} = "${barcodebuddy}/index.php";
scannerSource = "example/grabInput.py";
inherit (barcodebuddy-scanner) installPhase postInstall;
}

View file

@ -0,0 +1,63 @@
{
stdenvNoCC,
fetchpatch,
makeWrapper,
barcodebuddy,
curl,
evtest,
screen,
lib,
enableCurl ? true,
enablePhp ? false,
php,
...
}: let
inherit (lib.lists) optional optionals;
inherit (lib.strings) makeBinPath;
in
stdenvNoCC.mkDerivation {
pname = "barcodebuddy-scanner";
inherit (barcodebuddy) version src;
patches = [
(fetchpatch {
name = "barcodebuddy-grab-input.patch";
url = "https://github.com/gensokyo-zone/barcodebuddy/commit/9497d88b7971f2b47c9dcc32183721e059cd6d1d.patch";
sha256 = "sha256-1HV5VMlXR4VoMo01KhlZ3bTdVLMJ08qzFqhqK4hBHdg=";
})
];
skipConfigure = true;
skipBuild = true;
nativeBuildInputs = [
makeWrapper
];
scannerSource = "example/grabInput.sh";
scannerPath = makeBinPath (
[evtest]
++ optional enableCurl curl
++ optionals enablePhp [screen php]
);
installPhase = ''
runHook preInstall
install -Dm 0755 $scannerSource $out/bin/barcodebuddy-grab-input
runHook postInstall
'';
postInstall = ''
wrapProgram $out/bin/barcodebuddy-grab-input \
--set-default SCRIPT_LOCATION "''${barcodebuddyScript-/var/www/html/barcodebuddy/index.php}" \
--prefix PATH : "$scannerPath"
'';
meta =
barcodebuddy.meta
// {
mainProgram = "barcodebuddy-grab-input";
};
}