soapysdr: cleanup expression
- Format it with nixpkgs-fmt. - Patch fixed upstream issue only once, using fetchpatch. - Use `lib.optionals` consistently. - Use `lib.pipe` to write `lndir` commands for postFixup. - Use `finalAttrs.version` as much as possible. - Use passthru.searchPath to expose it for other packages to use (like Gnuradio's wrapper).
This commit is contained in:
parent
7f2d93dda9
commit
7bd68a8bde
@ -1,66 +1,83 @@
|
||||
{ stdenv, lib, lndir, makeWrapper
|
||||
, fetchFromGitHub, cmake
|
||||
, libusb-compat-0_1, pkg-config
|
||||
{ stdenv
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, fetchpatch
|
||||
, cmake
|
||||
, pkg-config
|
||||
, makeWrapper
|
||||
, libusb-compat-0_1
|
||||
, ncurses
|
||||
, usePython ? false
|
||||
, python ? null
|
||||
, ncurses, swig2
|
||||
, extraPackages ? []
|
||||
, testers
|
||||
, swig2
|
||||
, extraPackages ? [ ]
|
||||
, buildPackages
|
||||
, testers
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
version = "0.8.1";
|
||||
modulesVersion = with lib; versions.major version + "." + versions.minor version;
|
||||
modulesPath = "lib/SoapySDR/modules" + modulesVersion;
|
||||
extraPackagesSearchPath = lib.makeSearchPath modulesPath extraPackages;
|
||||
|
||||
in stdenv.mkDerivation (finalAttrs: {
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "soapysdr";
|
||||
inherit version;
|
||||
version = "0.8.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "pothosware";
|
||||
repo = "SoapySDR";
|
||||
rev = "soapy-sdr-${version}";
|
||||
rev = "soapy-sdr-${finalAttrs.version}";
|
||||
sha256 = "19f2x0pkxvf9figa0pl6xqlcz8fblvqb19mcnj632p0l8vk6qdv2";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# see https://github.com/pothosware/SoapySDR/issues/352 for upstream issue
|
||||
./fix-pkgconfig.patch
|
||||
# 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 makeWrapper pkg-config ];
|
||||
buildInputs = [ libusb-compat-0_1 ncurses ]
|
||||
++ lib.optionals usePython [ python swig2 ];
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
makeWrapper
|
||||
];
|
||||
buildInputs = [
|
||||
libusb-compat-0_1
|
||||
ncurses
|
||||
] ++ lib.optionals usePython [
|
||||
python
|
||||
swig2
|
||||
];
|
||||
|
||||
propagatedBuildInputs = lib.optional usePython python.pkgs.numpy;
|
||||
propagatedBuildInputs = lib.optionals usePython [
|
||||
python.pkgs.numpy
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DCMAKE_BUILD_TYPE=Release"
|
||||
] ++ lib.optional usePython "-DUSE_PYTHON_CONFIG=ON";
|
||||
] ++ lib.optionals usePython [
|
||||
"-DUSE_PYTHON_CONFIG=ON"
|
||||
];
|
||||
|
||||
# https://github.com/pothosware/SoapySDR/issues/352
|
||||
postPatch = ''
|
||||
substituteInPlace lib/SoapySDR.in.pc \
|
||||
--replace '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ \
|
||||
--replace '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
'';
|
||||
|
||||
postFixup = lib.optionalString (lib.length extraPackages != 0) ''
|
||||
postFixup = lib.optionalString (extraPackages != [ ]) (
|
||||
# Join all plugins via symlinking
|
||||
for i in ${toString extraPackages}; do
|
||||
${buildPackages.xorg.lndir}/bin/lndir -silent $i $out
|
||||
done
|
||||
# Needed for at least the remote plugin server
|
||||
for file in $out/bin/*; do
|
||||
wrapProgram "$file" --prefix SOAPY_SDR_PLUGIN_PATH : ${lib.escapeShellArg extraPackagesSearchPath}
|
||||
done
|
||||
'';
|
||||
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;
|
||||
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";
|
||||
|
@ -1,14 +0,0 @@
|
||||
diff --git a/lib/SoapySDR.in.pc b/lib/SoapySDR.in.pc
|
||||
index a1ca698..fd2f4c0 100644
|
||||
--- a/lib/SoapySDR.in.pc
|
||||
+++ b/lib/SoapySDR.in.pc
|
||||
@@ -1,7 +1,5 @@
|
||||
-prefix=@CMAKE_INSTALL_PREFIX@
|
||||
-exec_prefix=${prefix}
|
||||
-libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
|
||||
Name: Soapy SDR
|
||||
Description: Vendor and platform neutral SDR interface library.
|
Loading…
Reference in New Issue
Block a user