summary refs log tree commit diff
path: root/pkgs/applications/misc/electrum/default.nix
diff options
context:
space:
mode:
authorarcnmx <arcnmx@users.noreply.github.com>2019-07-11 07:08:57 -0700
committerarcnmx <arcnmx@users.noreply.github.com>2019-07-11 09:32:27 -0700
commit36f9da4ec43b849f913faefa52db49900ce59d53 (patch)
treeb0c949efb04178f8a005673f8ac929c2e1e5ec1a /pkgs/applications/misc/electrum/default.nix
parent769f992fbcc8257cc89e74db1add01796c9c0909 (diff)
downloadnixpkgs-36f9da4ec43b849f913faefa52db49900ce59d53.tar
nixpkgs-36f9da4ec43b849f913faefa52db49900ce59d53.tar.gz
nixpkgs-36f9da4ec43b849f913faefa52db49900ce59d53.tar.bz2
nixpkgs-36f9da4ec43b849f913faefa52db49900ce59d53.tar.lz
nixpkgs-36f9da4ec43b849f913faefa52db49900ce59d53.tar.xz
nixpkgs-36f9da4ec43b849f913faefa52db49900ce59d53.tar.zst
nixpkgs-36f9da4ec43b849f913faefa52db49900ce59d53.zip
electrum: optional qt5 and darwin fixes
qt5 is often broken on darwin, and it's a massive closure when there's
a curses interface and CLI to use instead.
Diffstat (limited to 'pkgs/applications/misc/electrum/default.nix')
-rw-r--r--pkgs/applications/misc/electrum/default.nix30
1 files changed, 22 insertions, 8 deletions
diff --git a/pkgs/applications/misc/electrum/default.nix b/pkgs/applications/misc/electrum/default.nix
index 61819f15f3a..5233aaf8fcd 100644
--- a/pkgs/applications/misc/electrum/default.nix
+++ b/pkgs/applications/misc/electrum/default.nix
@@ -1,4 +1,5 @@
 { stdenv, fetchurl, fetchFromGitHub, python3, python3Packages, zbar, secp256k1
+, enableQt ? !stdenv.isDarwin
 
 
 # for updater.nix
@@ -16,6 +17,15 @@
 let
   version = "3.3.8";
 
+  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"
+    else "libzbar${stdenv.hostPlatform.extensions.sharedLibrary}";
+
   # Not provided in official source releases, which are what upstream signs.
   tests = fetchFromGitHub {
     owner = "spesmilo";
@@ -56,9 +66,7 @@ python3Packages.buildPythonApplication rec {
     protobuf
     pyaes
     pycryptodomex
-    pyqt5
     pysocks
-    qdarkstyle
     qrcode
     requests
     tlslite-ng
@@ -70,15 +78,20 @@ python3Packages.buildPythonApplication rec {
 
     # TODO plugins
     # amodem
-  ];
+  ] ++ stdenv.lib.optionals enableQt [ pyqt5 qdarkstyle ];
 
   preBuild = ''
     sed -i 's,usr_share = .*,usr_share = "'$out'/share",g' setup.py
-    sed -i "s|name = 'libzbar.*'|name='${zbar}/lib/libzbar.so'|" electrum/qrscanner.py
-    substituteInPlace ./electrum/ecc_fast.py --replace libsecp256k1.so.0 ${secp256k1}/lib/libsecp256k1.so.0
-  '';
-
-  postInstall = ''
+    substituteInPlace ./electrum/ecc_fast.py \
+      --replace ${libsecp256k1_name} ${secp256k1}/lib/libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary}
+  '' + (if enableQt then ''
+    substituteInPlace ./electrum/qrscanner.py \
+      --replace ${libzbar_name} ${zbar}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary}
+  '' else ''
+    sed -i '/qdarkstyle/d' contrib/requirements/requirements.txt
+  '');
+
+  postInstall = stdenv.lib.optionalString stdenv.isLinux ''
     # Despite setting usr_share above, these files are installed under
     # $out/nix ...
     mv $out/${python3.sitePackages}/nix/store"/"*/share $out
@@ -123,6 +136,7 @@ python3Packages.buildPythonApplication rec {
     '';
     homepage = https://electrum.org/;
     license = licenses.mit;
+    platforms = platforms.all;
     maintainers = with maintainers; [ ehmry joachifm np ];
   };
 }