2021-04-05 15:23:46 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-08-20 17:08:02 +00:00
|
|
|
, fetchurl
|
|
|
|
, fetchFromGitHub
|
2024-05-15 15:35:15 +00:00
|
|
|
, fetchpatch
|
2020-08-20 17:08:02 +00:00
|
|
|
, wrapQtAppsHook
|
|
|
|
, python3
|
|
|
|
, zbar
|
|
|
|
, secp256k1
|
|
|
|
, enableQt ? true
|
2023-02-09 11:40:11 +00:00
|
|
|
, callPackage
|
2024-01-25 14:12:00 +00:00
|
|
|
, qtwayland
|
2024-04-21 15:54:59 +00:00
|
|
|
, fetchPypi
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "4.5.4";
|
|
|
|
|
|
|
|
python = python3.override {
|
|
|
|
self = python;
|
|
|
|
packageOverrides = self: super: {
|
|
|
|
# Pin ledger-bitcoin to 0.2.1
|
|
|
|
ledger-bitcoin = super.ledger-bitcoin.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "0.2.1";
|
|
|
|
format = "pyproject";
|
|
|
|
src = fetchPypi {
|
|
|
|
pname = "ledger_bitcoin";
|
|
|
|
inherit version;
|
|
|
|
hash = "sha256-AWl/q2MzzspNIo6yf30S92PgM/Ygsb+1lJsg7Asztso=";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
libsecp256k1_name =
|
2023-07-15 17:15:38 +00:00
|
|
|
if stdenv.isLinux then "libsecp256k1.so.{v}"
|
|
|
|
else if stdenv.isDarwin then "libsecp256k1.{v}.dylib"
|
2020-04-24 23:36:52 +00:00
|
|
|
else "libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}";
|
|
|
|
|
|
|
|
libzbar_name =
|
|
|
|
if stdenv.isLinux then "libzbar.so.0"
|
2022-08-12 12:06:08 +00:00
|
|
|
else if stdenv.isDarwin then "libzbar.0.dylib"
|
2020-04-24 23:36:52 +00:00
|
|
|
else "libzbar${stdenv.hostPlatform.extensions.sharedLibrary}";
|
|
|
|
|
|
|
|
# Not provided in official source releases, which are what upstream signs.
|
|
|
|
tests = fetchFromGitHub {
|
|
|
|
owner = "spesmilo";
|
|
|
|
repo = "electrum";
|
|
|
|
rev = version;
|
2024-04-21 15:54:59 +00:00
|
|
|
sha256 = "sha256-fDu2PlEQOF7ftlS6dYw15S2XiAx+D/bng4zC9ELj6uk=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
postFetch = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
mv $out ./all
|
2024-02-29 20:09:43 +00:00
|
|
|
mv ./all/tests $out
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
2021-08-05 21:33:18 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
python.pkgs.buildPythonApplication {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "electrum";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://download.electrum.org/${version}/Electrum-${version}.tar.gz";
|
2024-04-21 15:54:59 +00:00
|
|
|
sha256 = "sha256-lDuwXhOjcbCx8x/oIoigrklDwCbhn1trf5lDf/X/1Qc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
# can't symlink, tests get confused
|
2024-02-29 20:09:43 +00:00
|
|
|
cp -ar ${tests} $sourceRoot/tests
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
nativeBuildInputs = lib.optionals enableQt [ wrapQtAppsHook ];
|
2024-01-25 14:12:00 +00:00
|
|
|
buildInputs = lib.optional (stdenv.isLinux && enableQt) qtwayland;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
propagatedBuildInputs = with python.pkgs; [
|
2020-04-24 23:36:52 +00:00
|
|
|
aiohttp
|
|
|
|
aiohttp-socks
|
2020-08-20 17:08:02 +00:00
|
|
|
aiorpcx
|
|
|
|
attrs
|
|
|
|
bitstring
|
2020-12-25 13:55:36 +00:00
|
|
|
cryptography
|
2020-04-24 23:36:52 +00:00
|
|
|
dnspython
|
|
|
|
jsonrpclib-pelix
|
|
|
|
matplotlib
|
|
|
|
pbkdf2
|
|
|
|
protobuf
|
|
|
|
pysocks
|
|
|
|
qrcode
|
|
|
|
requests
|
|
|
|
tlslite-ng
|
2024-01-25 14:12:00 +00:00
|
|
|
certifi
|
|
|
|
jsonpatch
|
2020-04-24 23:36:52 +00:00
|
|
|
# plugins
|
2023-03-15 16:39:30 +00:00
|
|
|
btchip-python
|
2023-04-29 16:46:19 +00:00
|
|
|
ledger-bitcoin
|
2020-04-24 23:36:52 +00:00
|
|
|
ckcc-protocol
|
|
|
|
keepkey
|
|
|
|
trezor
|
2024-04-21 15:54:59 +00:00
|
|
|
bitbox02
|
|
|
|
cbor
|
|
|
|
pyserial
|
2021-08-05 21:33:18 +00:00
|
|
|
] ++ lib.optionals enableQt [
|
|
|
|
pyqt5
|
|
|
|
qdarkstyle
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
checkInputs = with python.pkgs; lib.optionals enableQt [
|
2024-02-29 20:09:43 +00:00
|
|
|
pyqt6
|
|
|
|
];
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
patches = [
|
|
|
|
# aiorpcx 0.23.1 compatibility
|
|
|
|
# Note: this patches `/run_electrum`.
|
|
|
|
# In the source repo, `/electrum/electrum`
|
|
|
|
# is a symlink to `../run_electrum`,
|
|
|
|
# so that path would also be affected by the patch.
|
|
|
|
# However, in the distribution tarball used here,
|
|
|
|
# `/electrum/electrum` is simply an exact copy of
|
|
|
|
# `/run_electrum` and is thereby *not* affected.
|
|
|
|
# So we have to manually copy the patched `/run_electrum`
|
|
|
|
# over `/electrum/electrum` after the patching (see below).
|
|
|
|
# XXX remove the copy command in `postPatch`
|
|
|
|
# as soon as the patch itself is removed!
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/spesmilo/electrum/commit/5f95d919dfa9868eaf82889903b94faa8c6443e0.patch";
|
|
|
|
hash = "sha256-cEkduLsL6A8qPhXS2KPQWzVtkQPYQhHSbuwQ2SnanHw=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2022-10-06 18:32:54 +00:00
|
|
|
postPatch = ''
|
2024-05-15 15:35:15 +00:00
|
|
|
# copy the patched `/run_electrum` over `/electrum/electrum`
|
|
|
|
# so the aiorpcx compatibility patch is used
|
|
|
|
cp run_electrum electrum/electrum
|
|
|
|
|
2022-10-06 18:32:54 +00:00
|
|
|
# make compatible with protobuf4 by easing dependencies ...
|
|
|
|
substituteInPlace ./contrib/requirements/requirements.txt \
|
2023-04-29 16:46:19 +00:00
|
|
|
--replace "protobuf>=3.20,<4" "protobuf>=3.20"
|
2022-10-06 18:32:54 +00:00
|
|
|
# ... and regenerating the paymentrequest_pb2.py file
|
|
|
|
protoc --python_out=. electrum/paymentrequest.proto
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace ./electrum/ecc_fast.py \
|
|
|
|
--replace ${libsecp256k1_name} ${secp256k1}/lib/libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
'' + (if enableQt then ''
|
|
|
|
substituteInPlace ./electrum/qrscanner.py \
|
|
|
|
--replace ${libzbar_name} ${zbar.lib}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
'' else ''
|
|
|
|
sed -i '/qdarkstyle/d' contrib/requirements/requirements.txt
|
|
|
|
'');
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
postInstall = lib.optionalString stdenv.isLinux ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace $out/share/applications/electrum.desktop \
|
|
|
|
--replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum %u"' \
|
|
|
|
"Exec=$out/bin/electrum %u" \
|
|
|
|
--replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum --testnet %u"' \
|
|
|
|
"Exec=$out/bin/electrum --testnet %u"
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
postFixup = lib.optionalString enableQt ''
|
2020-04-24 23:36:52 +00:00
|
|
|
wrapQtApp $out/bin/electrum
|
|
|
|
'';
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
nativeCheckInputs = with python.pkgs; [ pytestCheckHook pyaes pycryptodomex ];
|
2020-12-25 13:55:36 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
pytestFlagsArray = [ "tests" ];
|
2020-12-25 13:55:36 +00:00
|
|
|
|
|
|
|
postCheck = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
$out/bin/electrum help >/dev/null
|
|
|
|
'';
|
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
passthru.updateScript = callPackage ./update.nix { };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2022-12-28 21:21:41 +00:00
|
|
|
description = "Lightweight Bitcoin wallet";
|
2020-04-24 23:36:52 +00:00
|
|
|
longDescription = ''
|
|
|
|
An easy-to-use Bitcoin client featuring wallets generated from
|
|
|
|
mnemonic seeds (in addition to other, more advanced, wallet options)
|
|
|
|
and the ability to perform transactions without downloading a copy
|
|
|
|
of the blockchain.
|
|
|
|
'';
|
|
|
|
homepage = "https://electrum.org/";
|
2021-07-24 12:14:16 +00:00
|
|
|
downloadPage = "https://electrum.org/#download";
|
|
|
|
changelog = "https://github.com/spesmilo/electrum/blob/master/RELEASE-NOTES";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.all;
|
2024-04-21 15:54:59 +00:00
|
|
|
maintainers = with maintainers; [ joachifm np prusnak chewblacka ];
|
2024-01-25 14:12:00 +00:00
|
|
|
mainProgram = "electrum";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|