From b979f51af48514b06cc9bfb43700b54cc06c18ab Mon Sep 17 00:00:00 2001 From: Bignaux Ronan Date: Wed, 4 Mar 2020 18:22:38 +0100 Subject: [PATCH] soulseekqt: refactoring using appimageTools --- .../networking/p2p/soulseekqt/default.nix | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/pkgs/applications/networking/p2p/soulseekqt/default.nix b/pkgs/applications/networking/p2p/soulseekqt/default.nix index be9d59caeb2..a5e8d85f128 100644 --- a/pkgs/applications/networking/p2p/soulseekqt/default.nix +++ b/pkgs/applications/networking/p2p/soulseekqt/default.nix @@ -1,60 +1,51 @@ { stdenv, lib, fetchzip, mkDerivation +, appimageTools , autoPatchelfHook -, dbus , desktop-file-utils -, fontconfig , imagemagick -, libjson , qtmultimedia -, radare2 -, jq -, squashfsTools -, zlib }: mkDerivation rec { pname = "soulseekqt"; version = "2018-1-30"; + name="${pname}-${version}"; src = fetchzip { url = "https://www.slsknet.org/SoulseekQt/Linux/SoulseekQt-${version}-64bit-appimage.tgz"; sha256 = "16ncnvv8h33f161mgy7qc0wjvvqahsbwvby65qhgfh9pbbgb4xgg"; - }; + }; + + appextracted = appimageTools.extractType2 { + inherit name; + src="${src}/SoulseekQt-2018-1-30-64bit.AppImage"; + }; dontBuild = true; - - nativeBuildInputs = [ imagemagick radare2 jq autoPatchelfHook squashfsTools - desktop-file-utils ]; + dontConfigure = true; + + nativeBuildInputs = [ imagemagick autoPatchelfHook desktop-file-utils ]; buildInputs = [ qtmultimedia stdenv.cc.cc ]; - # avoid usage of appimage's runner option --appimage-extract - postUnpack = '' - cd $sourceRoot - - # 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)') - - unsquashfs -o $offset *.AppImage - sourceRoot=squashfs-root - ''; - installPhase = '' + # directory in /nix/store so readonly + cd $appextracted 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 + --set-key Categories --set-value Network default.desktop + mv $out/share/applications/default.desktop $out/share/applications/SoulseekQt.desktop #TODO: write generic code to read icon path from $binary.desktop + icon="$(readlink .DirIcon)" 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 + convert -resize "$size"x"$size" $icon $out/share/icons/hicolor/"$size"x"$size"/apps/$icon done '';