nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 191 lines 5.3 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 fetchFromGitHub, 6 wrapQtAppsHook, 7 python3, 8 zbar, 9 secp256k1, 10 enableQt ? true, 11 qtwayland, 12}: 13 14let 15 version = "4.2.2.1"; 16 17 libsecp256k1_name = 18 if stdenv.hostPlatform.isLinux then 19 "libsecp256k1.so.0" 20 else if stdenv.hostPlatform.isDarwin then 21 "libsecp256k1.0.dylib" 22 else 23 "libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}"; 24 25 libzbar_name = 26 if stdenv.hostPlatform.isLinux then 27 "libzbar.so.0" 28 else if stdenv.hostPlatform.isDarwin then 29 "libzbar.0.dylib" 30 else 31 "libzbar${stdenv.hostPlatform.extensions.sharedLibrary}"; 32 33 # Not provided in official source releases, which are what upstream signs. 34 tests = fetchFromGitHub { 35 owner = "pooler"; 36 repo = "electrum-ltc"; 37 rev = version; 38 sha256 = "sha256-qu72LIV07pgHqvKv+Kcw9ZmNk6IBz+4/vdJELlT5tE4="; 39 40 postFetch = '' 41 mv $out ./all 42 mv ./all/electrum_ltc/tests $out 43 ''; 44 }; 45 46in 47 48python3.pkgs.buildPythonApplication { 49 pname = "electrum-ltc"; 50 inherit version; 51 format = "setuptools"; 52 53 src = fetchurl { 54 url = "https://electrum-ltc.org/download/Electrum-LTC-${version}.tar.gz"; 55 hash = "sha256-7F28cve+HD5JDK5igfkGD/NvTCfA33g+DmQJ5mwPM9Q="; 56 }; 57 58 postUnpack = '' 59 # can't symlink, tests get confused 60 cp -ar ${tests} $sourceRoot/electrum_ltc/tests 61 ''; 62 63 nativeBuildInputs = lib.optionals enableQt [ wrapQtAppsHook ]; 64 65 propagatedBuildInputs = 66 with python3.pkgs; 67 [ 68 aiohttp 69 aiohttp-socks 70 aiorpcx 71 attrs 72 bitstring 73 cryptography 74 dnspython 75 jsonrpclib-pelix 76 matplotlib 77 pbkdf2 78 protobuf 79 py-scrypt 80 pysocks 81 qrcode 82 requests 83 certifi 84 # plugins 85 btchip-python 86 ckcc-protocol 87 keepkey 88 trezor 89 distutils 90 ] 91 ++ lib.optionals enableQt [ 92 pyqt5 93 qdarkstyle 94 ]; 95 96 patches = [ 97 # electrum-ltc attempts to pin to aiorpcX < 0.23, but nixpkgs 98 # has moved to newer versions. 99 # 100 # electrum-ltc hasn't been updated in some time, so we replicate 101 # the patch from electrum (BTC) and alter it to be usable with 102 # electrum-ltc. 103 # 104 # Similar to the BTC patch, we need to overwrite the symlink 105 # at electrum_ltc/electrum-ltc with the patched run_electrum 106 # in postPatch. 107 ./ltc-aiorpcX-version-bump.patch 108 ]; 109 110 postPatch = '' 111 # copy the patched `/run_electrum` over `/electrum/electrum` 112 # so the aiorpcx compatibility patch is used 113 cp run_electrum electrum_ltc/electrum-ltc 114 115 # refresh stale generated code, per electrum_ltc/paymentrequest.py line 40 116 protoc --proto_path=electrum_ltc/ --python_out=electrum_ltc/ electrum_ltc/paymentrequest.proto 117 ''; 118 119 preBuild = '' 120 sed -i 's,usr_share = .*,usr_share = "'$out'/share",g' setup.py 121 substituteInPlace ./electrum_ltc/ecc_fast.py \ 122 --replace ${libsecp256k1_name} ${secp256k1}/lib/libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary} 123 '' 124 + ( 125 if enableQt then 126 '' 127 substituteInPlace ./electrum_ltc/qrscanner.py \ 128 --replace ${libzbar_name} ${zbar.lib}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary} 129 '' 130 else 131 '' 132 sed -i '/qdarkstyle/d' contrib/requirements/requirements.txt 133 '' 134 ); 135 136 postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' 137 # Despite setting usr_share above, these files are installed under 138 # $out/nix ... 139 mv $out/${python3.sitePackages}/nix/store"/"*/share $out 140 rm -rf $out/${python3.sitePackages}/nix 141 142 substituteInPlace $out/share/applications/electrum-ltc.desktop \ 143 --replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum-ltc %u"' \ 144 "Exec=$out/bin/electrum-ltc %u" \ 145 --replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum-ltc --testnet %u"' \ 146 "Exec=$out/bin/electrum-ltc --testnet %u" 147 148 ''; 149 150 postFixup = lib.optionalString enableQt '' 151 wrapQtApp $out/bin/electrum-ltc 152 ''; 153 154 nativeCheckInputs = with python3.pkgs; [ 155 pytestCheckHook 156 pyaes 157 pycryptodomex 158 ]; 159 buildInputs = lib.optional stdenv.hostPlatform.isLinux qtwayland; 160 161 enabledTestPaths = [ "electrum_ltc/tests" ]; 162 163 disabledTests = [ 164 "test_loop" # test tries to bind 127.0.0.1 causing permission error 165 "test_is_ip_address" # fails spuriously https://github.com/spesmilo/electrum/issues/7307 166 # electrum_ltc.lnutil.RemoteMisbehaving: received commitment_signed without pending changes 167 "test_reestablish_replay_messages_rev_then_sig" 168 "test_reestablish_replay_messages_sig_then_rev" 169 # stuck on hydra 170 "test_reestablish_with_old_state" 171 ]; 172 173 postCheck = '' 174 $out/bin/electrum-ltc help >/dev/null 175 ''; 176 177 meta = with lib; { 178 description = "Lightweight Litecoin Client"; 179 mainProgram = "electrum-ltc"; 180 longDescription = '' 181 Electrum-LTC is a simple, but powerful Litecoin wallet. A unique secret 182 phrase (or seed) leaves intruders stranded and your peace of mind 183 intact. Keep it on paper, or in your head... and never worry about losing 184 your litecoins to theft or hardware failure. 185 ''; 186 homepage = "https://electrum-ltc.org/"; 187 license = licenses.mit; 188 platforms = platforms.all; 189 maintainers = with maintainers; [ bbjubjub ]; 190 }; 191}