2021-02-05 17:12:51 +00:00
|
|
|
{ lib
|
2021-12-06 16:07:01 +00:00
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchurl
|
2021-12-06 16:07:01 +00:00
|
|
|
, fetchFromGitHub
|
2020-09-25 04:45:31 +00:00
|
|
|
, wrapQtAppsHook
|
2021-12-06 16:07:01 +00:00
|
|
|
, python3
|
|
|
|
, zbar
|
|
|
|
, secp256k1
|
|
|
|
, enableQt ? true
|
2024-01-25 14:12:00 +00:00
|
|
|
, qtwayland
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
let
|
2022-08-12 12:06:08 +00:00
|
|
|
version = "4.2.2.1";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
libsecp256k1_name =
|
|
|
|
if stdenv.isLinux then "libsecp256k1.so.0"
|
|
|
|
else if stdenv.isDarwin then "libsecp256k1.0.dylib"
|
|
|
|
else "libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}";
|
|
|
|
|
|
|
|
libzbar_name =
|
|
|
|
if stdenv.isLinux then "libzbar.so.0"
|
2022-12-28 21:21:41 +00:00
|
|
|
else if stdenv.isDarwin then "libzbar.0.dylib"
|
2021-12-06 16:07:01 +00:00
|
|
|
else "libzbar${stdenv.hostPlatform.extensions.sharedLibrary}";
|
|
|
|
|
|
|
|
# Not provided in official source releases, which are what upstream signs.
|
|
|
|
tests = fetchFromGitHub {
|
|
|
|
owner = "pooler";
|
|
|
|
repo = "electrum-ltc";
|
|
|
|
rev = version;
|
2022-08-12 12:06:08 +00:00
|
|
|
sha256 = "sha256-qu72LIV07pgHqvKv+Kcw9ZmNk6IBz+4/vdJELlT5tE4=";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
postFetch = ''
|
2021-12-06 16:07:01 +00:00
|
|
|
mv $out ./all
|
|
|
|
mv ./all/electrum_ltc/tests $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
python3.pkgs.buildPythonApplication {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "electrum-ltc";
|
2021-12-06 16:07:01 +00:00
|
|
|
inherit version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://electrum-ltc.org/download/Electrum-LTC-${version}.tar.gz";
|
2022-08-12 12:06:08 +00:00
|
|
|
sha256 = "sha256-7F28cve+HD5JDK5igfkGD/NvTCfA33g+DmQJ5mwPM9Q=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
postUnpack = ''
|
|
|
|
# can't symlink, tests get confused
|
|
|
|
cp -ar ${tests} $sourceRoot/electrum_ltc/tests
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
nativeBuildInputs = lib.optionals enableQt [ wrapQtAppsHook ];
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
propagatedBuildInputs = with python3.pkgs; [
|
2021-12-06 16:07:01 +00:00
|
|
|
aiohttp
|
|
|
|
aiohttp-socks
|
|
|
|
aiorpcx
|
|
|
|
attrs
|
|
|
|
bitstring
|
|
|
|
cryptography
|
2020-04-24 23:36:52 +00:00
|
|
|
dnspython
|
|
|
|
jsonrpclib-pelix
|
2021-12-06 16:07:01 +00:00
|
|
|
matplotlib
|
|
|
|
pbkdf2
|
|
|
|
protobuf
|
2024-01-13 08:15:51 +00:00
|
|
|
py-scrypt
|
2020-04-24 23:36:52 +00:00
|
|
|
pysocks
|
2021-12-06 16:07:01 +00:00
|
|
|
qrcode
|
|
|
|
requests
|
|
|
|
tlslite-ng
|
2024-01-25 14:12:00 +00:00
|
|
|
certifi
|
2021-12-06 16:07:01 +00:00
|
|
|
# plugins
|
2023-03-15 16:39:30 +00:00
|
|
|
btchip-python
|
2021-12-06 16:07:01 +00:00
|
|
|
ckcc-protocol
|
|
|
|
keepkey
|
|
|
|
trezor
|
|
|
|
] ++ lib.optionals enableQt [
|
|
|
|
pyqt5
|
|
|
|
qdarkstyle
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
patches = [
|
|
|
|
# electrum-ltc attempts to pin to aiorpcX < 0.23, but nixpkgs
|
|
|
|
# has moved to newer versions.
|
|
|
|
#
|
|
|
|
# electrum-ltc hasn't been updated in some time, so we replicate
|
|
|
|
# the patch from electrum (BTC) and alter it to be usable with
|
|
|
|
# electrum-ltc.
|
|
|
|
#
|
|
|
|
# Similar to the BTC patch, we need to overwrite the symlink
|
|
|
|
# at electrum_ltc/electrum-ltc with the patched run_electrum
|
|
|
|
# in postPatch.
|
|
|
|
./ltc-aiorpcX-version-bump.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# copy the patched `/run_electrum` over `/electrum/electrum`
|
|
|
|
# so the aiorpcx compatibility patch is used
|
|
|
|
cp run_electrum electrum_ltc/electrum-ltc
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preBuild = ''
|
|
|
|
sed -i 's,usr_share = .*,usr_share = "'$out'/share",g' setup.py
|
2021-12-06 16:07:01 +00:00
|
|
|
substituteInPlace ./electrum_ltc/ecc_fast.py \
|
|
|
|
--replace ${libsecp256k1_name} ${secp256k1}/lib/libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
'' + (if enableQt then ''
|
|
|
|
substituteInPlace ./electrum_ltc/qrscanner.py \
|
|
|
|
--replace ${libzbar_name} ${zbar.lib}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
'' else ''
|
|
|
|
sed -i '/qdarkstyle/d' contrib/requirements/requirements.txt
|
|
|
|
'');
|
|
|
|
|
|
|
|
postInstall = lib.optionalString stdenv.isLinux ''
|
|
|
|
# Despite setting usr_share above, these files are installed under
|
|
|
|
# $out/nix ...
|
|
|
|
mv $out/${python3.sitePackages}/nix/store"/"*/share $out
|
|
|
|
rm -rf $out/${python3.sitePackages}/nix
|
|
|
|
|
|
|
|
substituteInPlace $out/share/applications/electrum-ltc.desktop \
|
|
|
|
--replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum-ltc %u"' \
|
|
|
|
"Exec=$out/bin/electrum-ltc %u" \
|
|
|
|
--replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum-ltc --testnet %u"' \
|
|
|
|
"Exec=$out/bin/electrum-ltc --testnet %u"
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
postFixup = lib.optionalString enableQt ''
|
|
|
|
wrapQtApp $out/bin/electrum-ltc
|
2020-09-25 04:45:31 +00:00
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = with python3.pkgs; [ pytestCheckHook pyaes pycryptodomex ];
|
2024-01-25 14:12:00 +00:00
|
|
|
buildInputs = lib.optional stdenv.isLinux qtwayland;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
pytestFlagsArray = [ "electrum_ltc/tests" ];
|
|
|
|
|
|
|
|
disabledTests = [
|
|
|
|
"test_loop" # test tries to bind 127.0.0.1 causing permission error
|
|
|
|
"test_is_ip_address" # fails spuriously https://github.com/spesmilo/electrum/issues/7307
|
|
|
|
];
|
|
|
|
|
|
|
|
postCheck = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
$out/bin/electrum-ltc help >/dev/null
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2021-12-06 16:07:01 +00:00
|
|
|
description = "Lightweight Litecoin Client";
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "electrum-ltc";
|
2020-04-24 23:36:52 +00:00
|
|
|
longDescription = ''
|
2021-12-06 16:07:01 +00:00
|
|
|
Electrum-LTC is a simple, but powerful Litecoin wallet. A unique secret
|
|
|
|
phrase (or “seed”) leaves intruders stranded and your peace of mind
|
|
|
|
intact. Keep it on paper, or in your head... and never worry about losing
|
|
|
|
your litecoins to theft or hardware failure.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
homepage = "https://electrum-ltc.org/";
|
|
|
|
license = licenses.mit;
|
2021-12-06 16:07:01 +00:00
|
|
|
platforms = platforms.all;
|
2024-02-29 20:09:43 +00:00
|
|
|
maintainers = with maintainers; [ bbjubjub ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|