aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/sdrconnect/default.nix
blob: d3db91eab354d2246eb0df40a3854b765dfbd517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{
  alsa-lib,
  autoPatchelfHook,
  copyDesktopItems,
  fetchurl,
  fontconfig,
  gcc,
  iconConvTools,
  icu,
  lib,
  libusb1,
  makeDesktopItem,
  stdenv,
  util-linux,
  xorg
}:

let

  hash = "83273bcd8";

  platforms = {
    aarch64-linux = {
      arch = "arm64";
      sha256 = "3e22926dcfbb85f27e1a42e53368d6794b83fbede114707fa4fedf053984323d";
    };

    x86_64-linux = {
      arch = "x64";
      sha256 = "81e94b31f6cd8699c51aa3f5742ce42dd4f3dbc94ce9d72d25c6e8a5851db664";
    };
  };

  version = "1.0.4";

  inherit (stdenv.hostPlatform) system;

in

  with platforms.${system} or (throw "Unsupported system: ${system}");

  stdenv.mkDerivation rec {
    inherit version;
    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 = [ "AudioVideo" "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";
    };
  }