bisq2: add webcam support (#440945)

This commit is contained in:
Peder Bergebakken Sundt
2025-09-09 23:13:11 +02:00
committed by GitHub
2 changed files with 88 additions and 17 deletions
+32 -17
View File
@@ -1,8 +1,7 @@
{
stdenvNoCC,
stdenv,
lib,
makeBinaryWrapper,
runtimeShell,
fetchurl,
makeDesktopItem,
copyDesktopItems,
@@ -10,11 +9,18 @@
jdk23,
dpkg,
writeShellScript,
bash,
tor,
zip,
gnupg,
coreutils,
# Used by the bundled webcam-app
libv4l,
# Used by the testing package bisq2-webcam-app
callPackage,
socat,
unzip,
}:
let
@@ -44,8 +50,18 @@ let
hash = "sha256-PrRYZLT0xv82dUscOBgQGKNf6zwzWUDhriAffZbNpmI=";
};
};
binPath = lib.makeBinPath [
coreutils
tor
];
libraryPath = lib.makeLibraryPath [
stdenv.cc.cc
libv4l
];
in
stdenvNoCC.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: rec {
inherit version;
pname = "bisq2";
@@ -137,21 +153,11 @@ stdenvNoCC.mkDerivation rec {
install -D -m 777 ${bisq-launcher ""} $out/bin/bisq2
substituteAllInPlace $out/bin/bisq2
wrapProgram $out/bin/bisq2 --prefix PATH : ${
lib.makeBinPath [
coreutils
tor
]
}
wrapProgram $out/bin/bisq2 --prefix PATH : ${binPath} --prefix LD_LIBRARY_PATH : ${libraryPath}
install -D -m 777 ${bisq-launcher "-Dglass.gtk.uiScale=2.0"} $out/bin/bisq2-hidpi
substituteAllInPlace $out/bin/bisq2-hidpi
wrapProgram $out/bin/bisq2-hidpi --prefix PATH : ${
lib.makeBinPath [
coreutils
tor
]
}
wrapProgram $out/bin/bisq2-hidpi --prefix PATH : ${binPath} --prefix LD_LIBRARY_PATH : ${libraryPath}
for n in 16 24 32 48 64 96 128 256; do
size=$n"x"$n
@@ -162,6 +168,15 @@ stdenvNoCC.mkDerivation rec {
runHook postInstall
'';
# The bisq2.webcam-app package is for maintainers to test scanning QR codes.
passthru.webcam-app = callPackage ./webcam-app.nix {
inherit
jdk
libraryPath
;
bisq2 = finalAttrs.finalPackage.out;
};
meta = {
description = "Decentralized bitcoin exchange network";
homepage = "https://bisq.network";
@@ -176,4 +191,4 @@ stdenvNoCC.mkDerivation rec {
"aarch64-linux"
];
};
}
})
+56
View File
@@ -0,0 +1,56 @@
# bisq2 contains a separate Java app which is used to scan Bitcoin Lightning QR codes.
# bisq2 communicates with the webcam app via a local TCP connection using a simple one-way protocol.
# Since the webcam app dynamically loads native code, this package is for maintainers to test QR code scanning without having to spend bitcoin to execute a trade.
# This package is exposed as an attribute of the bisq2 package; bisq2.webcam-app.
{
stdenv,
lib,
makeBinaryWrapper,
jdk,
writeShellScript,
unzip,
bisq2,
socat,
libraryPath,
}:
let
version = "1.0.0";
launcher = writeShellScript "bisq2-webcam-app-launcher" ''
${socat}/bin/socat TCP-LISTEN:8000,keepalive,fork STDIO &
socat_pid=$!
LD_LIBRARY_PATH=${libraryPath} "${lib.getExe jdk}" -classpath @out@/lib/app/webcam-app-${version}-all.jar:${bisq2}/lib/app/* bisq.webcam.WebcamAppLauncher "$@"
kill $socat_pid
'';
in
stdenv.mkDerivation rec {
inherit version;
pname = "bisq2-webcam-app";
src = bisq2;
dontUnpack = true;
nativeBuildInputs = [
makeBinaryWrapper
unzip
];
buildPhase = ''
# Extract the webcam app from Bisq2.
unzip ${bisq2}/lib/app/desktop.jar 'webcam-app/*'
unzip webcam-app/webcam-app-1.0.0.zip
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib/app $out/bin
cp webcam-app-${version}-all.jar $out/lib/app/
install -D -m 777 ${launcher} $out/bin/bisq2-webcam-app
substituteAllInPlace $out/bin/bisq2-webcam-app
runHook postInstall
'';
}