2022-06-16 17:23:12 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, makeWrapper
|
|
|
|
, fetchurl
|
|
|
|
, makeDesktopItem
|
|
|
|
, copyDesktopItems
|
|
|
|
, autoPatchelfHook
|
2022-12-17 10:02:37 +00:00
|
|
|
, openjdk
|
2022-06-16 17:23:12 +00:00
|
|
|
, gtk3
|
|
|
|
, gsettings-desktop-schemas
|
|
|
|
, writeScript
|
|
|
|
, bash
|
|
|
|
, gnugrep
|
|
|
|
, tor
|
|
|
|
, zlib
|
|
|
|
, openimajgrabber
|
|
|
|
, hwi
|
|
|
|
, imagemagick
|
2023-04-29 16:46:19 +00:00
|
|
|
, gzip
|
2022-06-16 17:23:12 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "sparrow";
|
2023-08-10 07:59:29 +00:00
|
|
|
version = "1.7.8";
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2022-11-21 17:40:18 +00:00
|
|
|
url = "https://github.com/sparrowwallet/${pname}/releases/download/${version}/${pname}-${version}-x86_64.tar.gz";
|
2023-08-10 07:59:29 +00:00
|
|
|
sha256 = "0nazqxffmai74x47dbkwryvx1pjm8k85rcfz5nr19h7fa1bj8rkc";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
launcher = writeScript "sparrow" ''
|
|
|
|
#! ${bash}/bin/bash
|
|
|
|
params=(
|
|
|
|
--module-path @out@/lib:@jdkModules@/modules
|
|
|
|
--add-opens javafx.graphics/com.sun.javafx.css=org.controlsfx.controls
|
|
|
|
--add-opens javafx.graphics/javafx.scene=org.controlsfx.controls
|
|
|
|
--add-opens javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls
|
|
|
|
--add-opens javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls
|
|
|
|
--add-opens javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls
|
|
|
|
--add-opens javafx.base/com.sun.javafx.event=org.controlsfx.controls
|
|
|
|
--add-opens javafx.controls/javafx.scene.control.cell=com.sparrowwallet.sparrow
|
|
|
|
--add-opens org.controlsfx.controls/impl.org.controlsfx.skin=com.sparrowwallet.sparrow
|
|
|
|
--add-opens org.controlsfx.controls/impl.org.controlsfx.skin=javafx.fxml
|
|
|
|
--add-opens javafx.graphics/com.sun.javafx.tk=centerdevice.nsmenufx
|
|
|
|
--add-opens javafx.graphics/com.sun.javafx.tk.quantum=centerdevice.nsmenufx
|
|
|
|
--add-opens javafx.graphics/com.sun.glass.ui=centerdevice.nsmenufx
|
|
|
|
--add-opens javafx.controls/com.sun.javafx.scene.control=centerdevice.nsmenufx
|
|
|
|
--add-opens javafx.graphics/com.sun.javafx.menu=centerdevice.nsmenufx
|
|
|
|
--add-opens javafx.graphics/com.sun.glass.ui=com.sparrowwallet.sparrow
|
2023-07-15 17:15:38 +00:00
|
|
|
--add-opens=javafx.graphics/javafx.scene.input=com.sparrowwallet.sparrow
|
2022-06-16 17:23:12 +00:00
|
|
|
--add-opens javafx.graphics/com.sun.javafx.application=com.sparrowwallet.sparrow
|
|
|
|
--add-opens java.base/java.net=com.sparrowwallet.sparrow
|
|
|
|
--add-opens java.base/java.io=com.google.gson
|
2023-07-15 17:15:38 +00:00
|
|
|
--add-opens=java.smartcardio/sun.security.smartcardio=com.sparrowwallet.sparrow
|
2022-06-16 17:23:12 +00:00
|
|
|
--add-reads com.sparrowwallet.merged.module=java.desktop
|
|
|
|
--add-reads com.sparrowwallet.merged.module=java.sql
|
|
|
|
--add-reads com.sparrowwallet.merged.module=com.sparrowwallet.sparrow
|
|
|
|
--add-reads com.sparrowwallet.merged.module=logback.classic
|
|
|
|
--add-reads com.sparrowwallet.merged.module=com.fasterxml.jackson.databind
|
|
|
|
--add-reads com.sparrowwallet.merged.module=com.fasterxml.jackson.annotation
|
|
|
|
--add-reads com.sparrowwallet.merged.module=com.fasterxml.jackson.core
|
|
|
|
--add-reads com.sparrowwallet.merged.module=co.nstant.in.cbor
|
|
|
|
-m com.sparrowwallet.sparrow
|
|
|
|
)
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
XDG_DATA_DIRS=${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}:${gtk3}/share/gsettings-schemas/${gtk3.name}:$XDG_DATA_DIRS ${openjdk}/bin/java ''${params[@]} $@
|
2022-06-16 17:23:12 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
torWrapper = writeScript "tor-wrapper" ''
|
|
|
|
#! ${bash}/bin/bash
|
|
|
|
|
|
|
|
exec ${tor}/bin/tor "$@"
|
|
|
|
'';
|
|
|
|
|
|
|
|
jdk-modules = stdenv.mkDerivation {
|
|
|
|
name = "jdk-modules";
|
2022-12-17 10:02:37 +00:00
|
|
|
nativeBuildInputs = [ openjdk ];
|
2022-06-16 17:23:12 +00:00
|
|
|
dontUnpack = true;
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
# Extract the JDK's JIMAGE and generate a list of modules.
|
|
|
|
mkdir modules
|
|
|
|
pushd modules
|
2022-12-17 10:02:37 +00:00
|
|
|
jimage extract ${openjdk}/lib/openjdk/lib/modules
|
2022-06-16 17:23:12 +00:00
|
|
|
ls | xargs -d " " -- echo > ../manifest.txt
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp manifest.txt $out/
|
|
|
|
cp -r modules/ $out/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
sparrow-modules = stdenv.mkDerivation {
|
|
|
|
pname = "sparrow-modules";
|
|
|
|
inherit version src;
|
2023-04-29 16:46:19 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper gzip gnugrep openjdk autoPatchelfHook stdenv.cc.cc.lib zlib ];
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
# Extract Sparrow's JIMAGE and generate a list of them.
|
|
|
|
mkdir modules
|
|
|
|
pushd modules
|
|
|
|
jimage extract ../lib/runtime/lib/modules
|
|
|
|
|
|
|
|
# Delete JDK modules
|
|
|
|
cat ${jdk-modules}/manifest.txt | xargs -I {} -- rm -fR {}
|
|
|
|
|
|
|
|
# Delete unneeded native libs.
|
|
|
|
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/freebsd-x86-64
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/freebsd-x86
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/linux-aarch64
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/linux-arm
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/linux-armel
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/linux-mips64el
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/linux-ppc
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/linux-ppc64le
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/linux-s390x
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/linux-x86
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/openbsd-x86-64
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/openbsd-x86
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/sunos-sparc
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/sunos-sparcv9
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/sunos-x86-64
|
|
|
|
rm -fR com.sparrowwallet.merged.module/com/sun/jna/sunos-x86
|
|
|
|
rm -fR com.github.sarxos.webcam.capture/com/github/sarxos/webcam/ds/buildin/lib/linux_armel
|
|
|
|
rm -fR com.github.sarxos.webcam.capture/com/github/sarxos/webcam/ds/buildin/lib/linux_armhf
|
|
|
|
rm -fR com.github.sarxos.webcam.capture/com/github/sarxos/webcam/ds/buildin/lib/linux_x86
|
|
|
|
rm com.github.sarxos.webcam.capture/com/github/sarxos/webcam/ds/buildin/lib/linux_x64/OpenIMAJGrabber.so
|
|
|
|
rm -fR com.nativelibs4java.bridj/org/bridj/lib/linux_arm32_armel
|
|
|
|
rm -fR com.nativelibs4java.bridj/org/bridj/lib/linux_armel
|
|
|
|
rm -fR com.nativelibs4java.bridj/org/bridj/lib/linux_armhf
|
|
|
|
rm -fR com.nativelibs4java.bridj/org/bridj/lib/linux_x86
|
|
|
|
rm -fR com.nativelibs4java.bridj/org/bridj/lib/sunos_x64
|
|
|
|
rm -fR com.nativelibs4java.bridj/org/bridj/lib/sunos_x86
|
|
|
|
rm -fR com.sparrowwallet.merged.module/linux-aarch64
|
|
|
|
rm -fR com.sparrowwallet.merged.module/linux-arm
|
|
|
|
rm -fR com.sparrowwallet.merged.module/linux-x86
|
|
|
|
rm com.sparrowwallet.sparrow/native/linux/x64/hwi
|
|
|
|
|
|
|
|
ls | xargs -d " " -- echo > ../manifest.txt
|
|
|
|
find . | grep "\.so$" | xargs -- chmod ugo+x
|
|
|
|
popd
|
|
|
|
|
|
|
|
# Replace the embedded Tor binary (which is in a Tar archive)
|
|
|
|
# with one from Nixpkgs.
|
2023-04-29 16:46:19 +00:00
|
|
|
gzip -c ${torWrapper} > tor.gz
|
|
|
|
cp tor.gz modules/kmp.tor.binary.linuxx64/kmptor/linux/x64/tor.gz
|
|
|
|
find modules
|
2022-06-16 17:23:12 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp manifest.txt $out/
|
|
|
|
cp -r modules/ $out/
|
|
|
|
ln -s ${openimajgrabber}/lib/OpenIMAJGrabber.so $out/modules/com.github.sarxos.webcam.capture/com/github/sarxos/webcam/ds/buildin/lib/linux_x64/OpenIMAJGrabber.so
|
|
|
|
ln -s ${hwi}/bin/hwi $out/modules/com.sparrowwallet.sparrow/native/linux/x64/hwi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2023-04-29 16:46:19 +00:00
|
|
|
inherit version src;
|
|
|
|
pname = "sparrow-unwrapped";
|
2022-06-16 17:23:12 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper copyDesktopItems ];
|
|
|
|
|
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
2023-07-15 17:15:38 +00:00
|
|
|
name = "sparrow-desktop";
|
|
|
|
exec = "sparrow-desktop";
|
|
|
|
icon = "sparrow-desktop";
|
2022-06-16 17:23:12 +00:00
|
|
|
desktopName = "Sparrow Bitcoin Wallet";
|
|
|
|
genericName = "Bitcoin Wallet";
|
2023-03-24 00:07:29 +00:00
|
|
|
categories = [ "Finance" "Network" ];
|
2022-11-21 17:40:18 +00:00
|
|
|
mimeTypes = [ "application/psbt" "application/bitcoin-transaction" "x-scheme-handler/bitcoin" "x-scheme-handler/auth47" "x-scheme-handler/lightning" ];
|
2023-03-24 00:07:29 +00:00
|
|
|
startupWMClass = "Sparrow";
|
2022-06-16 17:23:12 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
sparrow-icons = stdenv.mkDerivation {
|
|
|
|
inherit version src;
|
|
|
|
pname = "sparrow-icons";
|
|
|
|
nativeBuildInputs = [ imagemagick ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
for n in 16 24 32 48 64 96 128 256; do
|
|
|
|
size=$n"x"$n
|
|
|
|
mkdir -p $out/hicolor/$size/apps
|
2023-07-15 17:15:38 +00:00
|
|
|
convert lib/Sparrow.png -resize $size $out/hicolor/$size/apps/sparrow-desktop.png
|
2022-06-16 17:23:12 +00:00
|
|
|
done;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/bin $out
|
|
|
|
ln -s ${sparrow-modules}/modules $out/lib
|
2023-07-15 17:15:38 +00:00
|
|
|
install -D -m 777 ${launcher} $out/bin/sparrow-desktop
|
|
|
|
substituteAllInPlace $out/bin/sparrow-desktop
|
|
|
|
substituteInPlace $out/bin/sparrow-desktop --subst-var-by jdkModules ${jdk-modules}
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
mkdir -p $out/share/icons
|
|
|
|
ln -s ${sparrow-icons}/hicolor $out/share/icons
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
mkdir -p $out/etc/udev/rules.d
|
|
|
|
cp ${hwi}/lib/python*/site-packages/hwilib/udev/*.rules $out/etc/udev/rules.d
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A modern desktop Bitcoin wallet application supporting most hardware wallets and built on common standards such as PSBT, with an emphasis on transparency and usability.";
|
|
|
|
homepage = "https://sparrowwallet.com";
|
2022-06-26 10:26:21 +00:00
|
|
|
sourceProvenance = with sourceTypes; [
|
|
|
|
binaryBytecode
|
|
|
|
binaryNativeCode
|
|
|
|
];
|
2022-06-16 17:23:12 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ emmanuelrosa _1000101 ];
|
|
|
|
platforms = [ "x86_64-linux" ];
|
2023-07-15 17:15:38 +00:00
|
|
|
mainProgram = "sparrow-desktop";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
}
|