Last active
January 5, 2021 18:46
-
-
Save oneingan/903e633c7c7f4b4fda9e53ca74bb0810 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import ../nixpkgs {}; | |
let | |
jdk = openjdk11.overrideAttrs (oldAttrs: rec { | |
buildInputs = lib.remove gnome2.gnome_vfs oldAttrs.buildInputs; | |
NIX_LDFLAGS = builtins.replaceStrings [ "-lgnomevfs-2" ] [ "" ] oldAttrs.NIX_LDFLAGS; | |
}); | |
version = "1.5.1"; | |
name = "bisq-desktop"; | |
src = (fetchgit rec { | |
url = https://github.com/bisq-network/bisq; | |
rev = "v${version}"; | |
sha256 = "03gl2pymz7777b12zzk1sqmyipjbn2594gqm1s0hdzn4g6rcz7f8"; | |
postFetch = '' | |
cd $out | |
git clone $url | |
cd bisq | |
git lfs install --force --local | |
git lfs pull | |
cp -v p2p/src/main/resources/* $out/p2p/src/main/resources/ | |
cd .. | |
rm -rf bisq | |
''; | |
}).overrideAttrs (oldAttrs: { | |
nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [ git-lfs ]; | |
}); | |
grpc = callPackage ./grpc-java.nix {}; | |
gradle = (gradleGen.override { | |
java = jdk; | |
}).gradle_5_6; | |
# fake build to pre-download deps into fixed-output derivation | |
deps = stdenv.mkDerivation { | |
name = "${name}-deps"; | |
inherit src; | |
buildInputs = [ gradle perl unzip zip ]; | |
patchPhase = '' | |
substituteInPlace ./build.gradle \ | |
--replace 'artifact = "com.google.protobuf:protoc:''${protocVersion}"' "path = '${protobuf3_10}/bin/protoc'" | |
substituteInPlace ./build.gradle \ | |
--replace 'artifact = "io.grpc:protoc-gen-grpc-java:''${grpcVersion}"' "path = '${grpc}/bin/protoc-gen-rpc-java'" | |
''; | |
buildPhase = '' | |
export GRADLE_USER_HOME=$(mktemp -d) | |
gradle --no-daemon desktop:build --exclude-task desktop:test | |
''; | |
# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar) | |
installPhase = '' | |
find $GRADLE_USER_HOME -type f -regex '.*\.\(jar\|pom\)' \ | |
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \ | |
| sh | |
''; | |
dontStrip = true; | |
outputHashAlgo = "sha256"; | |
outputHashMode = "recursive"; | |
outputHash = "1jgl54xyiq9p64891sx750s4wg9agrbidmfkqjfj3cbq40xipk0p"; | |
}; | |
in stdenv.mkDerivation { | |
inherit name src; | |
nativeBuildInputs = [ makeWrapper ]; | |
buildInputs = [ gradle ps tor ]; | |
buildPhase = '' | |
export GRADLE_USER_HOME=$(mktemp -d) | |
( | |
mkdir lib | |
substituteInPlace build.gradle \ | |
--replace 'mavenCentral()' 'mavenLocal(); maven { url uri("${deps}") }' \ | |
--replace 'jcenter()' 'mavenLocal(); maven { url uri("${deps}") }' \ | |
--replace 'artifact = "com.google.protobuf:protoc:''${protocVersion}"' "path = '${protobuf3_10}/bin/protoc'" \ | |
--replace 'artifact = "io.grpc:protoc-gen-grpc-java:''${grpcVersion}"' "path = '${grpc}/bin/protoc-gen-rpc-java'" | |
sed -i 's/^.*com.github.JesusMcCloud.tor-binary:tor-binary-linux64.*$//g' gradle/witness/gradle-witness.gradle | |
gradle --offline --no-daemon desktop:build --exclude-task desktop:test | |
) | |
''; | |
installPhase = '' | |
mkdir -p $out/lib | |
cp -r lib/* $out/lib | |
for jar in $out/lib/*.jar; do | |
classpath="$classpath:$jar" | |
done | |
mkdir -p $out/bin | |
cp bisq-* $out/bin | |
makeWrapper ${jdk}/bin/java $out/bin/bisq-desktop-wrapped \ | |
--add-flags "-classpath $classpath bisq.desktop.app.BisqAppMain" \ | |
--add-flags "-torControlPort 9051" | |
''; | |
meta = with stdenv.lib; { | |
description = "The decentralized bitcoin exchange network"; | |
homepage = "https://bisq.network"; | |
license = licenses.mit; | |
maintainers = [ maintainers.juaningan ]; | |
platforms = [ "x86_64-linux" ]; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
PASS=$(tor --hash-password 1234) | |
TMPDIR=$(mktemp -d) | |
tor --ControlPort 9051 --ControlPortWriteToFile $TMPDIR/port --CookieAuthFile $TMPDIR/cookie --CookieAuthentication 1 --RunAsDaemon 1 | |
exec "./result/bin/bisq-desktop-wrapped" --torControlCookieFile=$TMPDIR/cookie --torControlUseSafeCookieAuth "${extraFlagsArray[@]}" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, ...}: | |
pkgs.stdenv.mkDerivation { | |
name = "protoc-gen-grpc-java"; | |
version = "1.25.0"; | |
src = ./protoc-gen-grpc-java-1.25.0-linux-x86_64.exe; | |
nativeBuildInputs = [ | |
pkgs.autoPatchelfHook | |
]; | |
dontUnpack = true; | |
installPhase = '' | |
install -m755 -D $src $out/bin/protoc-gen-rpc-java | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment