nixpkgs/pkgs/applications/radio/soapysdr/default.nix
2024-11-16 23:38:15 -08:00

85 lines
2.0 KiB
Nix

{
stdenv,
lib,
fetchFromGitHub,
cmake,
pkg-config,
makeWrapper,
libusb-compat-0_1,
ncurses,
usePython ? false,
python ? null,
swig,
extraPackages ? [ ],
buildPackages,
testers,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "soapysdr";
version = "0.8.2-pre";
src = fetchFromGitHub {
owner = "pothosware";
repo = "SoapySDR";
# Instead of applying several patches for Python 3.12 compat, just take the latest, from:
# use old get python lib for v2 (#437)
rev = "8c6cb7c5223fad995e355486527589c63aa3b21e";
hash = "sha256-CKasL1mlpeuxXyPe6VDdAvb1l5a1cwWgyP7XX1aM73I=";
};
nativeBuildInputs = [
cmake
pkg-config
makeWrapper
];
buildInputs =
[
libusb-compat-0_1
ncurses
]
++ lib.optionals usePython [
python
swig
];
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
numinit
];
mainProgram = "SoapySDRUtil";
pkgConfigModules = [ "SoapySDR" ];
platforms = platforms.unix;
};
})