gnuradio.pkgs: init

- Write a `mkDerivation` and `mkDerivationWith` function for gnuradio,
  like qt5.
- qradiolink, gqrx: Use gnuradio's callPackage and mkDerivation.
- Use gnuradio.callPackage to define all gnuradio.pkgs.
- Move all gnuradio packages expressions to pkgs/development/gnuradio-modules/ -
  modeled after Python's.
- Add more paths to gnuradio's wrapper - add the extra packages as
  python modules, and add their executables with proper env vars
  wrapping.

Co-authored-by: Frederik Rietdijk <fridh@fridh.nl>
This commit is contained in:
Doron Behar
2021-03-13 12:46:59 +02:00
co-authored by Frederik Rietdijk
parent 7690f9a312
commit 2d08e55e9b
20 changed files with 581 additions and 367 deletions
+7 -1
View File
@@ -221,11 +221,17 @@ let
buildInputs
disallowedReferences
postInstall
passthru
doCheck
dontWrapPythonPrograms
meta
;
passthru = shared.passthru // {
# Deps that are potentially overriden and are used inside GR plugins - the same version must
inherit boost;
} // lib.optionalAttrs (hasFeature "gr-uhd" features) {
inherit uhd;
};
cmakeFlags = shared.cmakeFlags
# From some reason, if these are not set, libcodec2 and gsm are
# not detected properly (slightly different then what's in
-53
View File
@@ -1,53 +0,0 @@
{ lib
, stdenv
, fetchFromGitHub
, cmake
, pkg-config
, boost
, gnuradio
, makeWrapper
, cppunit
, gr-osmosdr
, log4cpp
, pythonSupport ? true
, python
, swig
, fetchpatch
}:
stdenv.mkDerivation {
pname = "gr-ais";
version = "2015-12-20";
src = fetchFromGitHub {
owner = "bistromath";
repo = "gr-ais";
rev = "cdc1f52745853f9c739c718251830eb69704b26e";
sha256 = "1vl3kk8xr2mh5lf31zdld7yzmwywqffffah8iblxdzblgsdwxfl6";
};
patches = [
(fetchpatch {
url = "https://github.com/bistromath/gr-ais/commit/8502d0252a2a1a9b8d1a71795eaeb5d820684054.patch";
sha256 = "1cwalphldvf6dbhzwz1gi53z0cb4921qsvlz4138q7m6dxccvssg";
})
];
nativeBuildInputs = [ cmake makeWrapper pkg-config ];
buildInputs = [ boost gnuradio cppunit gr-osmosdr log4cpp ]
++ lib.optionals pythonSupport [ python swig ];
postInstall = ''
for prog in "$out"/bin/*; do
wrapProgram "$prog" --set PYTHONPATH $PYTHONPATH:$(toPythonPath "$out")
done
'';
meta = with lib; {
description = "Gnuradio block for ais";
homepage = "https://github.com/bistromath/gr-ais";
license = licenses.gpl3Plus;
platforms = platforms.linux ++ platforms.darwin;
maintainers = with maintainers; [ mog ];
};
}
@@ -228,6 +228,14 @@ let
dontWrapQtApps
meta
;
passthru = shared.passthru // {
# Deps that are potentially overriden and are used inside GR plugins - the same version must
inherit boost;
} // lib.optionalAttrs (hasFeature "gr-uhd" features) {
inherit uhd;
} // lib.optionalAttrs (hasFeature "gr-qtgui" features) {
inherit (libsForQt5) qwt;
};
cmakeFlags = shared.cmakeFlags
# From some reason, if these are not set, libcodec2 and gsm are not
# detected properly. NOTE: qradiolink needs libcodec2 to be detected in
-37
View File
@@ -1,37 +0,0 @@
{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, boost, gnuradio, log4cpp
, makeWrapper, cppunit, libosmocore, gr-osmosdr
, pythonSupport ? true, python, swig
}:
assert pythonSupport -> python != null && swig != null;
stdenv.mkDerivation {
pname = "gr-gsm";
version = "2016-08-25";
src = fetchFromGitHub {
owner = "ptrkrysik";
repo = "gr-gsm";
rev = "3ca05e6914ef29eb536da5dbec323701fbc2050d";
sha256 = "13nnq927kpf91iqccr8db9ripy5czjl5jiyivizn6bia0bam2pvx";
};
nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [
boost gnuradio makeWrapper cppunit libosmocore gr-osmosdr log4cpp
] ++ lib.optionals pythonSupport [ python swig ];
postInstall = ''
for prog in "$out"/bin/*; do
wrapProgram "$prog" --set PYTHONPATH $PYTHONPATH:${gr-osmosdr}/lib/${python.libPrefix}/site-packages:$(toPythonPath "$out")
done
'';
meta = with lib; {
description = "Gnuradio block for gsm";
homepage = "https://github.com/ptrkrysik/gr-gsm";
license = licenses.gpl3Plus;
platforms = platforms.linux;
maintainers = with maintainers; [ mog ];
};
}
@@ -1,38 +0,0 @@
{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, boost, gnuradio
, pythonSupport ? true, python, swig, limesuite, log4cpp
} :
assert pythonSupport -> python != null && swig != null;
let
version = "2.0.0";
in stdenv.mkDerivation {
pname = "gr-limesdr";
inherit version;
src = fetchFromGitHub {
owner = "myriadrf";
repo = "gr-limesdr";
rev = "v${version}";
sha256 = "0ldqvfwl0gil89l9s31fjf9d7ki0dk572i8vna336igfaz348ypq";
};
nativeBuildInputs = [
cmake
pkg-config
] ++ lib.optionals pythonSupport [ swig ];
buildInputs = [
boost gnuradio limesuite log4cpp
] ++ lib.optionals pythonSupport [ python ];
meta = with lib; {
description = "Gnuradio source and sink blocks for LimeSDR";
homepage = "https://wiki.myriadrf.org/Gr-limesdr_Plugin_for_GNURadio";
license = licenses.mit;
platforms = platforms.linux;
maintainers = [ maintainers.markuskowa ];
};
}
-37
View File
@@ -1,37 +0,0 @@
{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, boost, gnuradio, uhd
, makeWrapper, libsodium, cppunit, log4cpp
, pythonSupport ? true, python, swig
}:
assert pythonSupport -> python != null && swig != null;
stdenv.mkDerivation {
pname = "gr-nacl";
version = "2017-04-10";
src = fetchFromGitHub {
owner = "stwunsch";
repo = "gr-nacl";
rev = "15276bb0fcabf5fe4de4e58df3d579b5be0e9765";
sha256 = "018np0qlk61l7mlv3xxx5cj1rax8f1vqrsrch3higsl25yydbv7v";
};
nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [
boost gnuradio uhd makeWrapper libsodium cppunit log4cpp
] ++ lib.optionals pythonSupport [ python swig ];
postInstall = ''
for prog in "$out"/bin/*; do
wrapProgram "$prog" --set PYTHONPATH $PYTHONPATH:$(toPythonPath "$out")
done
'';
meta = with lib; {
description = "Gnuradio block for encryption";
homepage = "https://github.com/stwunsch/gr-nacl";
license = licenses.gpl3Plus;
platforms = platforms.linux ++ platforms.darwin;
maintainers = with maintainers; [ mog ];
};
}
@@ -1,45 +0,0 @@
{ lib, stdenv, fetchgit, cmake, pkg-config, makeWrapper
, boost
, pythonSupport ? true, python, swig
, airspy
, gnuradio
, hackrf
, libbladeRF
, rtl-sdr
, soapysdr-with-plugins
, uhd
, log4cpp
}:
assert pythonSupport -> python != null && swig != null;
stdenv.mkDerivation rec {
pname = "gr-osmosdr";
version = "0.1.5";
src = fetchgit {
url = "git://git.osmocom.org/gr-osmosdr";
rev = "v${version}";
sha256 = "0bf9bnc1c3c4yqqqgmg3nhygj6rcfmyk6pybi27f7461d2cw1drv";
};
nativeBuildInputs = [ cmake makeWrapper pkg-config ];
buildInputs = [
boost log4cpp airspy gnuradio hackrf libbladeRF rtl-sdr uhd
] ++ lib.optionals stdenv.isLinux [ soapysdr-with-plugins ]
++ lib.optionals pythonSupport [ python swig python.pkgs.cheetah ];
postInstall = ''
for prog in "$out"/bin/*; do
wrapProgram "$prog" --set PYTHONPATH $PYTHONPATH:$(toPythonPath "$out")
done
'';
meta = with lib; {
description = "Gnuradio block for OsmoSDR and rtl-sdr";
homepage = "https://sdr.osmocom.org/trac/wiki/GrOsmoSDR";
license = licenses.gpl3Plus;
platforms = platforms.linux ++ platforms.darwin;
maintainers = with maintainers; [ bjornfor ];
};
}
-36
View File
@@ -1,36 +0,0 @@
{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, boost, gnuradio, log4cpp
, makeWrapper, pythonSupport ? true, python, swig
}:
assert pythonSupport -> python != null && swig != null;
stdenv.mkDerivation rec {
pname = "gr-rds";
version = "1.1.0";
src = fetchFromGitHub {
owner = "bastibl";
repo = "gr-rds";
rev = "v${version}";
sha256 = "0jkzchvw0ivcxsjhi1h0mf7k13araxf5m4wi5v9xdgqxvipjzqfy";
};
nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [
boost gnuradio makeWrapper log4cpp
] ++ lib.optionals pythonSupport [ python swig ];
postInstall = ''
for prog in "$out"/bin/*; do
wrapProgram "$prog" --set PYTHONPATH $PYTHONPATH:$(toPythonPath "$out")
done
'';
meta = with lib; {
description = "Gnuradio block for radio data system";
homepage = "https://github.com/bastibl/gr-rds";
license = licenses.gpl2Plus;
platforms = platforms.linux ++ platforms.darwin;
maintainers = with maintainers; [ mog ];
};
}
+86 -39
View File
@@ -1,9 +1,16 @@
{ lib
, stdenv
# The unwrapped gnuradio derivation
, unwrapped
# If it's a minimal build, we don't want to wrap it with lndir and
# wrapProgram..
, wrap ? true
# For the wrapper
, makeWrapper
# For lndir
, xorg
# To define a the gnuradio.pkgs scope
, newScope
# For Emulating wrapGAppsHook
, gsettings-desktop-schemas
, glib
@@ -37,12 +44,16 @@ let
[]
)
) unwrapped.featuresInfo)
++ lib.optionals (unwrapped.hasFeature "python-support" unwrapped.features) [
# Add unwrapped itself as a python module
(unwrapped.python.pkgs.toPythonModule unwrapped)
]
++ lib.optionals
(unwrapped.hasFeature "python-support" unwrapped.features)
(
# Add unwrapped itself as a python module
[ (unwrapped.python.pkgs.toPythonModule unwrapped) ]
# Add all extraPackages as python modules
++ (builtins.map unwrapped.python.pkgs.toPythonModule extraPackages)
)
;
python3Env = unwrapped.python.withPackages(ps: pythonPkgs);
pythonEnv = unwrapped.python.withPackages(ps: pythonPkgs);
name = (lib.appendToName "wrapped" unwrapped).name;
makeWrapperArgs = builtins.concatStringsSep " " ([
@@ -88,48 +99,84 @@ let
(if unwrapped.versionAttr.major == "3.8" then
[
"--prefix" "QT_PLUGIN_PATH" ":"
"${lib.getBin unwrapped.qt.qtbase}/${unwrapped.qt.qtbase.qtPluginPrefix}"
"${
lib.makeSearchPath
unwrapped.qt.qtbase.qtPluginPrefix
(builtins.map lib.getBin [
unwrapped.qt.qtbase
unwrapped.qt.qtwayland
])
}"
"--prefix" "QML2_IMPORT_PATH" ":"
"${lib.getBin unwrapped.qt.qtbase}/${unwrapped.qt.qtbase.qtQmlPrefix}"
"${
lib.makeSearchPath
unwrapped.qt.qtbase.qtQmlPrefix
(builtins.map lib.getBin [
unwrapped.qt.qtbase
unwrapped.qt.qtwayland
])
}"
]
else
# TODO: Add here qt4 related environment for 3.7?
# Add here qt4 related environment for 3.7?
[
]
)
++ extraMakeWrapperArgs
);
in
stdenv.mkDerivation {
inherit name;
buildInputs = [
makeWrapper
xorg.lndir
];
passthru = {
inherit python3Env pythonPkgs unwrapped;
packages = import ../../../top-level/gnuradio-packages.nix {
inherit lib stdenv newScope;
gnuradio = unwrapped;
};
buildCommand = ''
mkdir $out
cd $out
lndir -silent ${unwrapped}
for i in $out/bin/*; do
if [[ ! -x "$i" ]]; then
continue
fi
cp -L "$i" "$i".tmp
mv -f "$i".tmp "$i"
if head -1 "$i" | grep -q ${unwrapped.python}; then
substituteInPlace "$i" \
--replace ${unwrapped.python} ${python3Env}
fi
wrapProgram "$i" ${makeWrapperArgs}
done
'';
inherit (unwrapped) meta;
}
passthru = unwrapped.passthru // {
inherit
pythonEnv
pythonPkgs
unwrapped
;
pkgs = packages;
};
self = if wrap then
stdenv.mkDerivation {
inherit name passthru;
buildInputs = [
makeWrapper
xorg.lndir
];
buildCommand = ''
mkdir $out
cd $out
lndir -silent ${unwrapped}
${lib.optionalString
(extraPackages != [])
(builtins.concatStringsSep "\n"
(builtins.map (pkg: ''
if [[ -d ${lib.getBin pkg}/bin/ ]]; then
lndir -silent ${pkg}/bin ./bin
fi
'') extraPackages)
)
}
for i in $out/bin/*; do
if [[ ! -x "$i" ]]; then
continue
fi
cp -L "$i" "$i".tmp
mv -f "$i".tmp "$i"
if head -1 "$i" | grep -q ${unwrapped.python}; then
substituteInPlace "$i" \
--replace ${unwrapped.python} ${pythonEnv}
fi
wrapProgram "$i" ${makeWrapperArgs}
done
'';
inherit (unwrapped) meta;
}
else
unwrapped.overrideAttrs(_: {
inherit passthru;
})
;
in self
+19 -13
View File
@@ -1,13 +1,22 @@
{ lib, stdenv, fetchFromGitHub, alsaLib, boost
, qt4, libpulseaudio, codec2, libconfig
, gnuradio, gr-osmosdr, gsm
, libopus, libjpeg, protobuf, qwt, speex
{ lib
, mkDerivation
, fetchFromGitHub
, libpulseaudio
, libconfig
, gnuradio
, gnuradioPackages
, gsm
, libopus
, libjpeg
, protobuf
, speex
, qmake4Hook
} :
let
version = "0.5.0";
in stdenv.mkDerivation {
in mkDerivation {
pname = "qradiolink";
inherit version;
@@ -32,20 +41,17 @@ in stdenv.mkDerivation {
'';
buildInputs = [
qt4
alsaLib
boost
libpulseaudio
codec2
libconfig
gsm
gnuradio
gr-osmosdr
gnuradioPackages.osmosdr
libopus
libjpeg
protobuf
speex
qwt
];
nativeBuildInputs = [
protobuf
qmake4Hook
];
enableParallelBuilding = true;