Merge pull request #130511 from emmanuelrosa/bisq-pkg-improvements

bisq-desktop: Nix package improvements
This commit is contained in:
Robert Hensing 2021-08-21 08:49:04 +02:00 committed by GitHub
commit b5836f7956
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 31 deletions

View file

@ -8,63 +8,50 @@
, openjdk11
, dpkg
, writeScript
, coreutils
, bash
, tor
, psmisc
, gnutar
, zip
, xz
}:
let
bisq-launcher = writeScript "bisq-launcher" ''
#! ${bash}/bin/bash
# Setup a temporary Tor instance
TMPDIR=$(${coreutils}/bin/mktemp -d)
CONTROLPORT=$(${coreutils}/bin/shuf -i 9100-9499 -n 1)
SOCKSPORT=$(${coreutils}/bin/shuf -i 9500-9999 -n 1)
${coreutils}/bin/head -c 1024 < /dev/urandom > $TMPDIR/cookie
# This is just a comment to convince Nix that Tor is a
# runtime dependency; The Tor binary is in a *.jar file,
# whereas Nix only scans for hashes in uncompressed text.
# ${bisq-tor}
${tor}/bin/tor --SocksPort $SOCKSPORT --ControlPort $CONTROLPORT \
--ControlPortWriteToFile $TMPDIR/port --CookieAuthFile $TMPDIR/cookie \
--CookieAuthentication 1 >$TMPDIR/tor.log --RunAsDaemon 1
JAVA_TOOL_OPTIONS="-XX:+UseG1GC -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:+UseStringDeduplication" bisq-desktop-wrapped "$@"
'';
torpid=$(${psmisc}/bin/fuser $CONTROLPORT/tcp)
bisq-tor = writeScript "bisq-tor" ''
#! ${bash}/bin/bash
echo Temp directory: $TMPDIR
echo Tor PID: $torpid
echo Tor control port: $CONTROLPORT
echo Tor SOCKS port: $SOCKSPORT
echo Tor log: $TMPDIR/tor.log
echo Bisq log file: $TMPDIR/bisq.log
JAVA_TOOL_OPTIONS="-XX:MaxRAM=4g" bisq-desktop-wrapped \
--torControlCookieFile=$TMPDIR/cookie \
--torControlUseSafeCookieAuth \
--torControlPort $CONTROLPORT "$@" > $TMPDIR/bisq.log
echo Bisq exited. Killing Tor...
kill $torpid
exec ${tor}/bin/tor "$@"
'';
in
stdenv.mkDerivation rec {
pname = "bisq-desktop";
version = "1.7.0";
version = "1.7.2";
src = fetchurl {
url = "https://github.com/bisq-network/bisq/releases/download/v${version}/Bisq-64bit-${version}.deb";
sha256 = "0crry5k7crmrqn14wxiyrnhk09ac8a9ksqrwwky7jsnyah0bx5k4";
sha256 = "0b2rh9sphc9wffkawprrl20frgv0rah7y2k5sfxpjc3shgkqsw80";
};
nativeBuildInputs = [ makeWrapper copyDesktopItems dpkg ];
nativeBuildInputs = [ makeWrapper copyDesktopItems imagemagick dpkg gnutar zip xz ];
desktopItems = [
(makeDesktopItem {
name = "Bisq";
exec = "bisq-desktop";
icon = "bisq";
desktopName = "Bisq";
desktopName = "Bisq ${version}";
genericName = "Decentralized bitcoin exchange";
categories = "Network;Utility;";
categories = "Network;P2P;";
})
];
@ -72,6 +59,16 @@ stdenv.mkDerivation rec {
dpkg -x $src .
'';
buildPhase = ''
# Replace the embedded Tor binary (which is in a Tar archive)
# with one from Nixpkgs.
mkdir -p native/linux/x64/
cp ${bisq-tor} ./tor
tar -cJf native/linux/x64/tor.tar.xz tor
zip -r opt/bisq/lib/app/desktop-${version}-all.jar native
'';
installPhase = ''
runHook preInstall
@ -86,13 +83,15 @@ stdenv.mkDerivation rec {
for n in 16 24 32 48 64 96 128 256; do
size=$n"x"$n
${imagemagick}/bin/convert opt/bisq/lib/Bisq.png -resize $size bisq.png
convert opt/bisq/lib/Bisq.png -resize $size bisq.png
install -Dm644 -t $out/share/icons/hicolor/$size/apps bisq.png
done;
runHook postInstall
'';
passthru.updateScript = ./update.sh;
meta = with lib; {
description = "A decentralized bitcoin exchange network";
homepage = "https://bisq.network";

View file

@ -0,0 +1,22 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq gnused gnupg common-updater-scripts
set -eu -o pipefail
version="$(curl -s https://api.github.com/repos/bisq-network/bisq/releases| jq '.[] | {name,prerelease} | select(.prerelease==false) | limit(1;.[])' | sed 's/[\"v]//g' | head -n 1)"
depname="Bisq-64bit-$version.deb"
src="https://github.com/bisq-network/bisq/releases/download/v$version/$depname"
signature="$src.asc"
key="CB36 D7D2 EBB2 E35D 9B75 500B CD5D C1C5 29CD FD3B"
pushd $(mktemp -d --suffix=-bisq-updater)
export GNUPGHOME=$PWD/gnupg
mkdir -m 700 -p "$GNUPGHOME"
curl -L -o "$depname" -- "$src"
curl -L -o signature.asc -- "$signature"
gpg --batch --recv-keys "$key"
gpg --batch --verify signature.asc "$depname"
sha256=$(nix-prefetch-url --type sha256 "file://$PWD/$depname")
popd
update-source-version bisq-desktop "$version" "$sha256"