From 65371bd75937ffe4efc3715a2dfcb37bec2e607b Mon Sep 17 00:00:00 2001 From: Mark Nipper Date: Sat, 14 Dec 2024 12:48:06 -0800 Subject: Update SDRconnect package definition to resemble https://discourse.nixos.org/t/packaging-unfree-binary-package-sdrconnect/40609/3 --- pkgs/sdrconnect/default.nix | 131 +++++++++++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 49 deletions(-) (limited to 'pkgs/sdrconnect/default.nix') diff --git a/pkgs/sdrconnect/default.nix b/pkgs/sdrconnect/default.nix index 30bd538..388419c 100644 --- a/pkgs/sdrconnect/default.nix +++ b/pkgs/sdrconnect/default.nix @@ -1,53 +1,86 @@ -{ fetchurl, lib, pkgs, stdenv }: +{ alsa-lib, autoPatchelfHook, copyDesktopItems, fetchurl, fontconfig, gcc, iconConvTools, icu, lib, libusb1, makeDesktopItem, stdenv, util-linux, xorg }: + let - pname = "sdrconnect"; -in -stdenv.mkDerivation { - inherit pname; - version = "1.0.3"; - src = fetchurl { - url = "https://www.sdrplay.com/software/SDRconnect_linux-x64_b6fce59a3.run"; - sha256 = "1c2d150df1aec3f15174986fe7f522ea98aa04f3536f941fcc98f099a798b835"; - }; + hash = "b6fce59a3"; - sourceRoot = "."; - unpackCmd = "bash $src --quiet --noexec --target ."; - - buildInputs = with pkgs; [ - alsa-lib - fontconfig.lib - icu - libusb1 - remarkable2-toolchain - stdenv.cc.cc.lib - util-linux.lib - xorg.libICE - xorg.libSM - xorg.libX11 - ]; - - installPhase = '' - runHook preInstall - mkdir -p $out/{bin,lib} $out/share/{doc,icons} - patchelf --set-interpreter ${pkgs.stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 SDRconnect - patchelf --set-rpath \$ORIGIN/../lib:${pkgs.alsa-lib}/lib:${pkgs.fontconfig.lib}/lib:${pkgs.icu}/lib:${pkgs.libusb1}/lib:${pkgs.remarkable2-toolchain}/lib:${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.util-linux.lib}/lib:${pkgs.xorg.libICE}/lib:${pkgs.xorg.libSM}/lib:${pkgs.xorg.libX11}/lib SDRconnect - patchelf --add-needed libSkiaSharp.so --add-needed libasound.so.2 --add-needed libfontconfig.so.1 --add-needed libstdc++.so.6 --add-needed libusb-1.0.so.0 --add-needed libuuid.so.1 --add-needed swig_bindings.so SDRconnect - mv SDRconnect $out/bin - mv libHarfBuzzSharp.so libSkiaSharp.so swig_bindings.so $out/lib - mv sdrconnect.ico $out/share/icons - mv sdrplay_license.txt $out/share/doc - rm install.sh - runHook postInstall - ''; - - dontFixup = true; - - meta = with lib; { - description = "sdrconnect"; - homepage = "https://www.sdrplay.com/sdrconnect/"; - sourceProvenance = with sourceTypes; [ binaryNativeCode ]; - license = licenses.unfree; - platforms = [ "x86_64-linux" ]; + platforms = { + aarch64-linux = { + arch = "arm64"; + sha256 = "8d354686700014c4bd606a959ee5e979b0601bef281a33c8d12e181819d9a641"; + }; + + x86_64-linux = { + arch = "x64"; + sha256 = "1c2d150df1aec3f15174986fe7f522ea98aa04f3536f941fcc98f099a798b835"; + }; }; -} + + version = "1.0.3"; + + inherit (stdenv.hostPlatform) system; + +in + + with platforms.${system} or (throw "Unsupported system: ${system}"); + + stdenv.mkDerivation rec { + pname = "sdrconnect"; + + src = fetchurl { + url = "https://www.sdrplay.com/software/SDRconnect_linux-${arch}_${hash}.run"; + inherit sha256; + }; + + nativeBuildInputs = [ autoPatchelfHook copyDesktopItems iconConvTools ]; + + buildInputs = [ + alsa-lib + fontconfig + libusb1 + util-linux # for libuuid + gcc.cc.lib # for libstdc++ + ]; + + runtimeDependencies = [ + icu + xorg.libX11 + xorg.libICE + xorg.libSM + ]; + + appendRunpaths = [ "${placeholder "out"}/lib" ]; + + unpackPhase = '' + bash $src --target . --noexec + ''; + + postInstall = '' + mkdir -p $out/bin $out/lib + cp SDRconnect $out/bin + cp *.so $out/lib + icoFileToHiColorTheme sdrconnect.ico sdrconnect $out + ''; + + desktopItems = with meta; [ + (makeDesktopItem { + name = pname; + icon = pname; + exec = mainProgram; + comment = description; + desktopName = "SDRconnect"; + genericName = "SDRplay Client"; + categories = [ "HamRadio" ]; + keywords = [ "Ham" "Radio" "SDR" ]; + }) + ]; + + meta = with lib; { + description = "Cross platform GUI client for SDRplay"; + homepage = "https://www.sdrplay.com/sdrconnect/"; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + license = licenses.unfree; + platforms = attrNames platforms; + mainProgram = "SDRconnect"; + }; + } -- cgit v1.2.3