about summary refs log tree commit diff
path: root/pkgs/applications/radio/soapysdr/default.nix
blob: ee03d67d59862bd878a3edcd13b57789c65008a6 (plain) (blame)
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
{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, cmake
, pkg-config
, makeWrapper
, libusb-compat-0_1
, ncurses
, usePython ? false
, python ? null
, swig2
, extraPackages ? [ ]
, buildPackages
, testers
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "soapysdr";
  version = "0.8.1";

  src = fetchFromGitHub {
    owner = "pothosware";
    repo = "SoapySDR";
    rev = "soapy-sdr-${finalAttrs.version}";
    sha256 = "19f2x0pkxvf9figa0pl6xqlcz8fblvqb19mcnj632p0l8vk6qdv2";
  };

  patches = [
    # Fix for https://github.com/pothosware/SoapySDR/issues/352
    (fetchpatch {
      url = "https://github.com/pothosware/SoapySDR/commit/10c05b3e52caaa421147d6b4623eccd3fc3be3f4.patch";
      hash = "sha256-D7so6NSZiU6SXbzns04Q4RjSZW0FJ+MYobvvVpVMjws=";
    })
  ];

  nativeBuildInputs = [
    cmake
    pkg-config
    makeWrapper
  ];
  buildInputs = [
    libusb-compat-0_1
    ncurses
  ] ++ lib.optionals usePython [
    python
    swig2
  ];

  propagatedBuildInputs = lib.optionals usePython [
    python.pkgs.numpy
  ];

  cmakeFlags = lib.optionals usePython [
    "-DUSE_PYTHON_CONFIG=ON"
  ];

  postFixup = lib.optionalString (extraPackages != [ ]) (
    # Join all plugins via symlinking
    lib.pipe extraPackages [
      (map (pkg: ''
        ${buildPackages.xorg.lndir}/bin/lndir -silent ${pkg} $out
      ''))
      lib.concatStrings
    ] + ''
      # Needed for at least the remote plugin server
      for file in $out/bin/*; do
          wrapProgram "$file" --prefix SOAPY_SDR_PLUGIN_PATH : ${lib.escapeShellArg (
            lib.makeSearchPath finalAttrs.passthru.searchPath extraPackages
          )}
      done
    ''
  );

  passthru = {
    tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
    searchPath = "lib/SoapySDR/modules${lib.versions.majorMinor finalAttrs.version}";
  };

  meta = with lib; {
    homepage = "https://github.com/pothosware/SoapySDR";
    description = "Vendor and platform neutral SDR support library";
    license = licenses.boost;
    maintainers = with maintainers; [ markuskowa ];
    mainProgram = "SoapySDRUtil";
    pkgConfigModules = [ "SoapySDR" ];
    platforms = platforms.unix;
  };
})