|
| 1 | +{ |
| 2 | + stdenvNoCC, |
| 3 | + lib, |
| 4 | + makeWrapper, |
| 5 | + runtimeShell, |
| 6 | + fetchurl, |
| 7 | + makeDesktopItem, |
| 8 | + copyDesktopItems, |
| 9 | + imagemagick, |
| 10 | + jdk23, |
| 11 | + dpkg, |
| 12 | + writeShellScript, |
| 13 | + bash, |
| 14 | + tor, |
| 15 | + zip, |
| 16 | + gnupg, |
| 17 | +}: |
| 18 | + |
| 19 | +let |
| 20 | + version = "2.1.2"; |
| 21 | + |
| 22 | + jdk = jdk23.override { enableJavaFX = true; }; |
| 23 | + |
| 24 | + bisq-launcher = |
| 25 | + args: |
| 26 | + writeShellScript "bisq-launcher" '' |
| 27 | + # This is just a comment to convince Nix that Tor is a |
| 28 | + # runtime dependency; The Tor binary is in a *.jar file, |
| 29 | + # whereas Nix only scans for hashes in uncompressed text. |
| 30 | + # ${lib.getExe' tor "tor"} |
| 31 | +
|
| 32 | + rm -fR $HOME/.local/share/Bisq2/tor |
| 33 | +
|
| 34 | + exec "${lib.getExe jdk}" -Djpackage.app-version=@version@ -classpath @out@/lib/app/desktop-app-launcher.jar:@out@/lib/app/* ${args} bisq.desktop_app_launcher.DesktopAppLauncher "$@" |
| 35 | + ''; |
| 36 | + |
| 37 | + # A given release will be signed by either Alejandro Garcia or Henrik Jannsen |
| 38 | + # as indicated in the file |
| 39 | + # https://github.com/bisq-network/bisq2/releases/download/v${version}/signingkey.asc |
| 40 | + publicKey = |
| 41 | + { |
| 42 | + "E222AA02" = fetchurl { |
| 43 | + url = "https://github.com/bisq-network/bisq2/releases/download/v${version}/E222AA02.asc"; |
| 44 | + sha256 = "sha256-31uBpe/+0QQwFyAsoCt1TUWRm0PHfCFOGOx1M16efoE="; |
| 45 | + }; |
| 46 | + |
| 47 | + "387C8307" = fetchurl { |
| 48 | + url = "https://github.com/bisq-network/bisq2/releases/download/v${version}/387C8307.asc"; |
| 49 | + sha256 = "sha256-PrRYZLT0xv82dUscOBgQGKNf6zwzWUDhriAffZbNpmI="; |
| 50 | + }; |
| 51 | + } |
| 52 | + ."387C8307"; |
| 53 | +in |
| 54 | +stdenvNoCC.mkDerivation rec { |
| 55 | + inherit version; |
| 56 | + |
| 57 | + pname = "bisq2"; |
| 58 | + |
| 59 | + src = fetchurl { |
| 60 | + url = "https://github.com/bisq-network/bisq2/releases/download/v${version}/Bisq-${version}.deb"; |
| 61 | + sha256 = "0zgv70xlz3c9mrwmiaa1dgagbc441ppk2vrkgard8zjrvk8rg7va"; |
| 62 | + |
| 63 | + # Verify the upstream Debian package prior to extraction. |
| 64 | + # See https://bisq.wiki/Bisq_2#Installation |
| 65 | + # This ensures that a successful build of this Nix package requires the Debian |
| 66 | + # package to pass verification. |
| 67 | + nativeBuildInputs = [ gnupg ]; |
| 68 | + downloadToTemp = true; |
| 69 | + |
| 70 | + postFetch = '' |
| 71 | + pushd $(mktemp -d) |
| 72 | + export GNUPGHOME=./gnupg |
| 73 | + mkdir -m 700 -p $GNUPGHOME |
| 74 | + ln -s $downloadedFile ./Bisq-${version}.deb |
| 75 | + ln -s ${signature} ./signature.asc |
| 76 | + gpg --import ${publicKey} |
| 77 | + gpg --batch --verify signature.asc Bisq-${version}.deb |
| 78 | + popd |
| 79 | + mv $downloadedFile $out |
| 80 | + ''; |
| 81 | + }; |
| 82 | + |
| 83 | + signature = fetchurl { |
| 84 | + url = "https://github.com/bisq-network/bisq2/releases/download/v${version}/Bisq-${version}.deb.asc"; |
| 85 | + sha256 = "sha256-WZhI8RDmb7nQqpCQJM86vrp8qQNg+mvRVdSPcDqgzxE="; |
| 86 | + }; |
| 87 | + |
| 88 | + nativeBuildInputs = [ |
| 89 | + copyDesktopItems |
| 90 | + dpkg |
| 91 | + imagemagick |
| 92 | + makeWrapper |
| 93 | + zip |
| 94 | + gnupg |
| 95 | + makeWrapper |
| 96 | + ]; |
| 97 | + |
| 98 | + desktopItems = [ |
| 99 | + (makeDesktopItem { |
| 100 | + name = "bisq2"; |
| 101 | + exec = "bisq2"; |
| 102 | + icon = "bisq2"; |
| 103 | + desktopName = "Bisq 2"; |
| 104 | + genericName = "Decentralized bitcoin exchange"; |
| 105 | + categories = [ |
| 106 | + "Network" |
| 107 | + "P2P" |
| 108 | + ]; |
| 109 | + }) |
| 110 | + |
| 111 | + (makeDesktopItem { |
| 112 | + name = "bisq2-hidpi"; |
| 113 | + exec = "bisq2-hidpi"; |
| 114 | + icon = "bisq2"; |
| 115 | + desktopName = "Bisq 2 (HiDPI)"; |
| 116 | + genericName = "Decentralized bitcoin exchange"; |
| 117 | + categories = [ |
| 118 | + "Network" |
| 119 | + "P2P" |
| 120 | + ]; |
| 121 | + }) |
| 122 | + ]; |
| 123 | + |
| 124 | + unpackPhase = '' |
| 125 | + dpkg -x $src . |
| 126 | + ''; |
| 127 | + |
| 128 | + buildPhase = '' |
| 129 | + # Replace the Tor binary embedded in tor.jar (which is in the zip archive tor.zip) |
| 130 | + # with the Tor binary from Nixpkgs. |
| 131 | +
|
| 132 | + makeWrapper ${lib.getExe' tor "tor"} ./tor |
| 133 | + zip tor.zip ./tor |
| 134 | + zip opt/bisq2/lib/app/tor.jar tor.zip |
| 135 | + ''; |
| 136 | + |
| 137 | + installPhase = '' |
| 138 | + runHook preInstall |
| 139 | +
|
| 140 | + mkdir -p $out/lib $out/bin |
| 141 | + cp -r opt/bisq2/lib/app $out/lib |
| 142 | +
|
| 143 | + install -D -m 777 ${bisq-launcher ""} $out/bin/bisq2 |
| 144 | + substituteAllInPlace $out/bin/bisq2 |
| 145 | +
|
| 146 | + install -D -m 777 ${bisq-launcher "-Dglass.gtk.uiScale=2.0"} $out/bin/bisq2-hidpi |
| 147 | + substituteAllInPlace $out/bin/bisq2-hidpi |
| 148 | +
|
| 149 | + for n in 16 24 32 48 64 96 128 256; do |
| 150 | + size=$n"x"$n |
| 151 | + magick convert opt/bisq2/lib/Bisq2.png -resize $size bisq2.png |
| 152 | + install -Dm644 -t $out/share/icons/hicolor/$size/apps bisq2.png |
| 153 | + done; |
| 154 | +
|
| 155 | + runHook postInstall |
| 156 | + ''; |
| 157 | + |
| 158 | + meta = with lib; { |
| 159 | + description = "Decentralized bitcoin exchange network"; |
| 160 | + homepage = "https://bisq.network"; |
| 161 | + mainProgram = "bisq2"; |
| 162 | + sourceProvenance = with sourceTypes; [ |
| 163 | + binaryBytecode |
| 164 | + ]; |
| 165 | + license = licenses.mit; |
| 166 | + maintainers = with maintainers; [ emmanuelrosa ]; |
| 167 | + platforms = [ "x86_64-linux" ]; |
| 168 | + }; |
| 169 | +} |
0 commit comments