about summary refs log tree commit diff
path: root/pkgs/applications/networking/p2p
diff options
context:
space:
mode:
authorBignaux Ronan <ronan@aimao.org>2019-12-09 21:28:44 +0100
committerBignaux Ronan <ronan@aimao.org>2020-03-04 16:15:19 +0100
commit30430c0b409c01267d747dfc8ec94a25237ef101 (patch)
treed1a81c3bf3b44f8db762ca601333a5bf6e1b695a /pkgs/applications/networking/p2p
parentbf83a7cc66f6e4157fd6514e22096495e1a3b5e0 (diff)
downloadnixlib-30430c0b409c01267d747dfc8ec94a25237ef101.tar
nixlib-30430c0b409c01267d747dfc8ec94a25237ef101.tar.gz
nixlib-30430c0b409c01267d747dfc8ec94a25237ef101.tar.bz2
nixlib-30430c0b409c01267d747dfc8ec94a25237ef101.tar.lz
nixlib-30430c0b409c01267d747dfc8ec94a25237ef101.tar.xz
nixlib-30430c0b409c01267d747dfc8ec94a25237ef101.tar.zst
nixlib-30430c0b409c01267d747dfc8ec94a25237ef101.zip
soulseekqt: fix icons, change unpack method, update homepage, more generic appimage handling
Diffstat (limited to 'pkgs/applications/networking/p2p')
-rw-r--r--pkgs/applications/networking/p2p/soulseekqt/default.nix61
1 files changed, 34 insertions, 27 deletions
diff --git a/pkgs/applications/networking/p2p/soulseekqt/default.nix b/pkgs/applications/networking/p2p/soulseekqt/default.nix
index b52320c96814..be9d59caeb25 100644
--- a/pkgs/applications/networking/p2p/soulseekqt/default.nix
+++ b/pkgs/applications/networking/p2p/soulseekqt/default.nix
@@ -1,11 +1,13 @@
-{ stdenv, lib, fetchurl, mkDerivation
+{ stdenv, lib, fetchzip, mkDerivation
 , autoPatchelfHook
 , dbus
 , desktop-file-utils
 , fontconfig
+, imagemagick
 , libjson
-, pythonPackages
 , qtmultimedia
+, radare2
+, jq
 , squashfsTools
 , zlib
 }:
@@ -14,46 +16,51 @@ mkDerivation rec {
   pname = "soulseekqt";
   version = "2018-1-30";
 
-  src = fetchurl {
-      urls = [
-        "https://www.dropbox.com/s/0vi87eef3ooh7iy/SoulseekQt-${version}.tgz"
-        "https://www.slsknet.org/SoulseekQt/Linux/SoulseekQt-${version}-64bit-appimage.tgz"
-      ];
-      sha256 = "0d1cayxr1a4j19bc5a3qp9pg22ggzmd55b6f5av3lc6lvwqqg4w6";
+  src = fetchzip {
+      url = "https://www.slsknet.org/SoulseekQt/Linux/SoulseekQt-${version}-64bit-appimage.tgz";
+      sha256 = "16ncnvv8h33f161mgy7qc0wjvvqahsbwvby65qhgfh9pbbgb4xgg";
     };
 
   dontBuild = true;
 
-  nativeBuildInputs = [ autoPatchelfHook pythonPackages.binwalk squashfsTools desktop-file-utils ];
+  nativeBuildInputs = [ imagemagick radare2 jq autoPatchelfHook squashfsTools
+    desktop-file-utils ];
   buildInputs = [ qtmultimedia stdenv.cc.cc ];
 
   # avoid usage of appimage's runner option --appimage-extract
-  unpackCmd = ''
-    export HOME=$(pwd) # workaround for binwalk
-    appimage=$(tar xvf $curSrc) && binwalk --quiet \
-       $appimage -D 'squashfs:squashfs:unsquashfs %e'
-    '';
+  postUnpack = ''
+    cd $sourceRoot
 
-  patchPhase = ''
-    cd squashfs-root/
-    binary="$(readlink AppRun)"
+    # multiarch offset one-liner using same method as AppImage
+    offset=$(r2 *.AppImage -nn -Nqc "pfj.elf_header @ 0" |\
+      jq 'map({(.name): .value}) | add | .shoff + (.shnum * .shentsize)')
 
-    # fixup desktop file
-    desktop-file-edit --set-key Exec --set-value $binary default.desktop
-    desktop-file-edit --set-key Comment --set-value "${meta.description}" default.desktop
-    desktop-file-edit --set-key Categories --set-value Network default.desktop
+    unsquashfs -o $offset *.AppImage
+    sourceRoot=squashfs-root
   '';
 
   installPhase = ''
-    mkdir -p $out/{bin,share/applications,share/icons/}
-    cp default.desktop $out/share/applications/$binary.desktop
-    cp soulseek.png $out/share/icons/
-    cp $binary $out/bin/
-  '';
+
+      binary="$(readlink AppRun)"
+      mv default.desktop $binary.desktop
+      install -Dm755 $binary -t $out/bin
+
+      # fixup and install desktop file
+      desktop-file-install --dir $out/share/applications \
+        --set-key Exec --set-value $binary \
+        --set-key Comment --set-value "${meta.description}" \
+        --set-key Categories --set-value Network $binary.desktop
+
+      #TODO: write generic code to read icon path from $binary.desktop
+      for size in 16 32 48 64 72 96 128 192 256 512 1024; do
+        mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
+        convert -resize "$size"x"$size" ./soulseek.png $out/share/icons/hicolor/"$size"x"$size"/apps/soulseek.png
+      done
+    '';
 
   meta = with lib; {
     description = "Official Qt SoulSeek client";
-    homepage = http://www.soulseekqt.net;
+    homepage = https://www.slsknet.org;
     license = licenses.unfree;
     maintainers = [ maintainers.genesis ];
     platforms = [ "x86_64-linux" ];