17 if stdenv.hostPlatform.isLinux then "libsecp256k1.so.0"
18 else if stdenv.hostPlatform.isDarwin then "libsecp256k1.0.dylib"
19 else "libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}";
22 if stdenv.hostPlatform.isLinux then "libzbar.so.0"
23 else if stdenv.hostPlatform.isDarwin then "libzbar.0.dylib"
24 else "libzbar${stdenv.hostPlatform.extensions.sharedLibrary}";
26 # Not provided in official source releases, which are what upstream signs.
27 tests = fetchFromGitHub {
29 repo = "electrum-ltc";
31 sha256 = "sha256-qu72LIV07pgHqvKv+Kcw9ZmNk6IBz+4/vdJELlT5tE4=";
35 mv ./all/electrum_ltc/tests $out
41 python3.pkgs.buildPythonApplication {
42 pname = "electrum-ltc";
46 url = "https://electrum-ltc.org/download/Electrum-LTC-${version}.tar.gz";
47 sha256 = "sha256-7F28cve+HD5JDK5igfkGD/NvTCfA33g+DmQJ5mwPM9Q=";
51 # can't symlink, tests get confused
52 cp -ar ${tests} $sourceRoot/electrum_ltc/tests
55 nativeBuildInputs = lib.optionals enableQt [ wrapQtAppsHook ];
57 propagatedBuildInputs = with python3.pkgs; [
79 ] ++ lib.optionals enableQt [
85 # electrum-ltc attempts to pin to aiorpcX < 0.23, but nixpkgs
86 # has moved to newer versions.
88 # electrum-ltc hasn't been updated in some time, so we replicate
89 # the patch from electrum (BTC) and alter it to be usable with
92 # Similar to the BTC patch, we need to overwrite the symlink
93 # at electrum_ltc/electrum-ltc with the patched run_electrum
95 ./ltc-aiorpcX-version-bump.patch
99 # copy the patched `/run_electrum` over `/electrum/electrum`
100 # so the aiorpcx compatibility patch is used
101 cp run_electrum electrum_ltc/electrum-ltc
105 sed -i 's,usr_share = .*,usr_share = "'$out'/share",g' setup.py
106 substituteInPlace ./electrum_ltc/ecc_fast.py \
107 --replace ${libsecp256k1_name} ${secp256k1}/lib/libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}
108 '' + (if enableQt then ''
109 substituteInPlace ./electrum_ltc/qrscanner.py \
110 --replace ${libzbar_name} ${zbar.lib}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary}
112 sed -i '/qdarkstyle/d' contrib/requirements/requirements.txt
115 postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
116 # Despite setting usr_share above, these files are installed under
118 mv $out/${python3.sitePackages}/nix/store"/"*/share $out
119 rm -rf $out/${python3.sitePackages}/nix
121 substituteInPlace $out/share/applications/electrum-ltc.desktop \
122 --replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum-ltc %u"' \
123 "Exec=$out/bin/electrum-ltc %u" \
124 --replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum-ltc --testnet %u"' \
125 "Exec=$out/bin/electrum-ltc --testnet %u"
129 postFixup = lib.optionalString enableQt ''
130 wrapQtApp $out/bin/electrum-ltc
133 nativeCheckInputs = with python3.pkgs; [ pytestCheckHook pyaes pycryptodomex ];
134 buildInputs = lib.optional stdenv.hostPlatform.isLinux qtwayland;
136 pytestFlagsArray = [ "electrum_ltc/tests" ];
139 "test_loop" # test tries to bind 127.0.0.1 causing permission error
140 "test_is_ip_address" # fails spuriously https://github.com/spesmilo/electrum/issues/7307
141 # electrum_ltc.lnutil.RemoteMisbehaving: received commitment_signed without pending changes
142 "test_reestablish_replay_messages_rev_then_sig"
143 "test_reestablish_replay_messages_sig_then_rev"
145 "test_reestablish_with_old_state"
149 $out/bin/electrum-ltc help >/dev/null
153 description = "Lightweight Litecoin Client";
154 mainProgram = "electrum-ltc";
156 Electrum-LTC is a simple, but powerful Litecoin wallet. A unique secret
157 phrase (or “seed”) leaves intruders stranded and your peace of mind
158 intact. Keep it on paper, or in your head... and never worry about losing
159 your litecoins to theft or hardware failure.
161 homepage = "https://electrum-ltc.org/";
162 license = licenses.mit;
163 platforms = platforms.all;
164 maintainers = with maintainers; [ bbjubjub ];