18 python = python3.override {
20 packageOverrides = self: super: {
21 # Pin ledger-bitcoin to 0.2.1
22 ledger-bitcoin = super.ledger-bitcoin.overridePythonAttrs (oldAttrs: rec {
26 pname = "ledger_bitcoin";
28 hash = "sha256-AWl/q2MzzspNIo6yf30S92PgM/Ygsb+1lJsg7Asztso=";
35 if stdenv.hostPlatform.isLinux then "libsecp256k1.so.{v}"
36 else if stdenv.hostPlatform.isDarwin then "libsecp256k1.{v}.dylib"
37 else "libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}";
40 if stdenv.hostPlatform.isLinux then "libzbar.so.0"
41 else if stdenv.hostPlatform.isDarwin then "libzbar.0.dylib"
42 else "libzbar${stdenv.hostPlatform.extensions.sharedLibrary}";
44 # Not provided in official source releases, which are what upstream signs.
45 tests = fetchFromGitHub {
49 sha256 = "sha256-CbhI/q+zjk9odxuvdzpogi046FqkedJooiQwS+WAkJ8=";
59 python.pkgs.buildPythonApplication {
64 url = "https://download.electrum.org/${version}/Electrum-${version}.tar.gz";
65 sha256 = "1jiagz9avkbd158pcip7p4wz0pdsxi94ndvg5p8afvshb32aqwav";
69 # can't symlink, tests get confused
70 cp -ar ${tests} $sourceRoot/tests
73 nativeBuildInputs = lib.optionals enableQt [ wrapQtAppsHook ];
74 buildInputs = lib.optional (stdenv.hostPlatform.isLinux && enableQt) qtwayland;
76 propagatedBuildInputs = with python.pkgs; [
102 ] ++ lib.optionals enableQt [
107 checkInputs = with python.pkgs; lib.optionals enableQt [
112 # make compatible with protobuf4 by easing dependencies ...
113 substituteInPlace ./contrib/requirements/requirements.txt \
114 --replace "protobuf>=3.20,<4" "protobuf>=3.20"
115 # ... and regenerating the paymentrequest_pb2.py file
116 protoc --python_out=. electrum/paymentrequest.proto
118 substituteInPlace ./electrum/ecc_fast.py \
119 --replace ${libsecp256k1_name} ${secp256k1}/lib/libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}
120 '' + (if enableQt then ''
121 substituteInPlace ./electrum/qrscanner.py \
122 --replace ${libzbar_name} ${zbar.lib}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary}
124 sed -i '/qdarkstyle/d' contrib/requirements/requirements.txt
127 postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
128 substituteInPlace $out/share/applications/electrum.desktop \
129 --replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum %u"' \
130 "Exec=$out/bin/electrum %u" \
131 --replace 'Exec=sh -c "PATH=\"\\$HOME/.local/bin:\\$PATH\"; electrum --testnet %u"' \
132 "Exec=$out/bin/electrum --testnet %u"
135 postFixup = lib.optionalString enableQt ''
136 wrapQtApp $out/bin/electrum
139 nativeCheckInputs = with python.pkgs; [ pytestCheckHook pyaes pycryptodomex ];
141 pytestFlagsArray = [ "tests" ];
144 $out/bin/electrum help >/dev/null
147 passthru.updateScript = callPackage ./update.nix { };
150 description = "Lightweight Bitcoin wallet";
152 An easy-to-use Bitcoin client featuring wallets generated from
153 mnemonic seeds (in addition to other, more advanced, wallet options)
154 and the ability to perform transactions without downloading a copy
157 homepage = "https://electrum.org/";
158 downloadPage = "https://electrum.org/#download";
159 changelog = "https://github.com/spesmilo/electrum/blob/master/RELEASE-NOTES";
160 license = licenses.mit;
161 platforms = platforms.all;
162 maintainers = with maintainers; [ joachifm np prusnak chewblacka ];
163 mainProgram = "electrum";