From 32e09278844c1bdb22d191710da4e87e60d35a55 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:17:05 +0100 Subject: [PATCH 1/3] Revert "electrum: fixup Exec lines in .desktop" This reverts commit a879c725525b2321f505519ff0c71f182518f438. It is no longer needed, as electrum removed the PATH manipulation: https://github.com/spesmilo/electrum/commit/f15abd7cbd55c82833ad621754d3420895414f75 However, this commit also deviates from a plain revert, as it adds an additional replacement command to still substitute the `--testnet` command line, as it was done before. Note: Those `--replace` calls are removed here in order to stricten substitute calls with `--replace-fail` in a follow-up commit. --- pkgs/applications/misc/electrum/default.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/misc/electrum/default.nix b/pkgs/applications/misc/electrum/default.nix index 219046157cf8..a0aa8aa031e4 100644 --- a/pkgs/applications/misc/electrum/default.nix +++ b/pkgs/applications/misc/electrum/default.nix @@ -108,10 +108,8 @@ python3.pkgs.buildPythonApplication rec { postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' 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" + --replace "Exec=electrum %u" "Exec=$out/bin/electrum %u" \ + --replace "Exec=electrum --testnet %u" "Exec=$out/bin/electrum --testnet %u" ''; postFixup = lib.optionalString enableQt '' From b0c4f34b535c4400f60bc4aa568adb39d53e2620 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:32:09 +0100 Subject: [PATCH 2/3] electrum: substitute with `--replace-fail` The old `--replace` is deprecated, we use `--replace-fail` so changes in source code that might invalidate substitute invocations get noticed. Cf. commit e07a2fab7f065c3fa084027f07dcf8cafbd19394 . --- pkgs/applications/misc/electrum/default.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/misc/electrum/default.nix b/pkgs/applications/misc/electrum/default.nix index a0aa8aa031e4..410cb3066189 100644 --- a/pkgs/applications/misc/electrum/default.nix +++ b/pkgs/applications/misc/electrum/default.nix @@ -87,18 +87,18 @@ python3.pkgs.buildPythonApplication rec { '' # make compatible with protobuf4 by easing dependencies ... substituteInPlace ./contrib/requirements/requirements.txt \ - --replace "protobuf>=3.20,<4" "protobuf>=3.20" + --replace-fail "protobuf>=3.20,<4" "protobuf>=3.20" # ... and regenerating the paymentrequest_pb2.py file protoc --python_out=. electrum/paymentrequest.proto substituteInPlace ./electrum/ecc_fast.py \ - --replace ${libsecp256k1_name} ${secp256k1}/lib/libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary} + --replace-fail ${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} + --replace-fail ${libzbar_name} ${zbar.lib}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary} '' else '' @@ -108,8 +108,8 @@ python3.pkgs.buildPythonApplication rec { postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' substituteInPlace $out/share/applications/electrum.desktop \ - --replace "Exec=electrum %u" "Exec=$out/bin/electrum %u" \ - --replace "Exec=electrum --testnet %u" "Exec=$out/bin/electrum --testnet %u" + --replace-fail "Exec=electrum %u" "Exec=$out/bin/electrum %u" \ + --replace-fail "Exec=electrum --testnet %u" "Exec=$out/bin/electrum --testnet %u" ''; postFixup = lib.optionalString enableQt '' From e3d7bbab8b3bad048037823b6200ae17471225d5 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:39:10 +0100 Subject: [PATCH 3/3] electrum: patch for aiorpcx 0.24 compatibility electrum is quite strict about the aiorpcx version is accepts. With commit 4bbf5300d44ee9420a59650ba668f70e3f101bde , Upstream already has a patch to extend the range of aiorpcx versions it permits: https://github.com/spesmilo/electrum/commit/171aa5ee5ad4e25b9da10f757d9d398e905b4945 As the patch does not cleanly apply to the distribution tarball we're using, we instead apply the required changes "by hand", with `substituteInPlace`. On top of the changes adapted from the upstream commit, we have to change the file `./electrum/electrum`: It is not part of the upstream source repository, but it gets created from `./run_electrum` when upstream creates the distribution tarball. Note that the commit at hand is similar to 0e513f0435b2edb2c53412df873b46c583b0f9b5 . --- pkgs/applications/misc/electrum/default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/applications/misc/electrum/default.nix b/pkgs/applications/misc/electrum/default.nix index 410cb3066189..43defb195023 100644 --- a/pkgs/applications/misc/electrum/default.nix +++ b/pkgs/applications/misc/electrum/default.nix @@ -85,6 +85,17 @@ python3.pkgs.buildPythonApplication rec { postPatch = '' + # fix compatibility with recent aiorpcx version + # (remove as soon as https://github.com/spesmilo/electrum/commit/171aa5ee5ad4e25b9da10f757d9d398e905b4945 is included in source tarball) + substituteInPlace ./contrib/requirements/requirements.txt \ + --replace-fail "aiorpcx>=0.22.0,<0.24" "aiorpcx>=0.22.0,<0.25" + substituteInPlace ./run_electrum \ + --replace-fail "if not ((0, 22, 0) <= aiorpcx._version < (0, 24)):" "if not ((0, 22, 0) <= aiorpcx._version < (0, 25)):" \ + --replace-fail "aiorpcX version {aiorpcx._version} does not match required: 0.22.0<=ver<0.24" "aiorpcX version {aiorpcx._version} does not match required: 0.22.0<=ver<0.25" + substituteInPlace ./electrum/electrum \ + --replace-fail "if not ((0, 22, 0) <= aiorpcx._version < (0, 24)):" "if not ((0, 22, 0) <= aiorpcx._version < (0, 25)):" \ + --replace-fail "aiorpcX version {aiorpcx._version} does not match required: 0.22.0<=ver<0.24" "aiorpcX version {aiorpcx._version} does not match required: 0.22.0<=ver<0.25" + # make compatible with protobuf4 by easing dependencies ... substituteInPlace ./contrib/requirements/requirements.txt \ --replace-fail "protobuf>=3.20,<4" "protobuf>=3.20"