diff options
Diffstat (limited to 'pkgs/applications/radio/gnuradio/default.nix')
-rw-r--r-- | pkgs/applications/radio/gnuradio/default.nix | 423 |
1 files changed, 273 insertions, 150 deletions
diff --git a/pkgs/applications/radio/gnuradio/default.nix b/pkgs/applications/radio/gnuradio/default.nix index dec968cd32d7..811eb37f4f31 100644 --- a/pkgs/applications/radio/gnuradio/default.nix +++ b/pkgs/applications/radio/gnuradio/default.nix @@ -1,165 +1,288 @@ { stdenv , fetchFromGitHub -, makeWrapper -, writeText -# Dependencies documented @ https://gnuradio.org/doc/doxygen/build_guide.html -# => core dependencies +, fetchpatch , cmake +# Remove gcc and python references +, removeReferencesTo , pkgconfig -, git -, boost , cppunit -, fftw -# => python wrappers -# May be able to upgrade to swig3 +, swig +, orc +, boost +, log4cpp +, mpir +, doxygen , python -, swig2 -, numpy -, scipy -, matplotlib -# => grc - the gnu radio companion -, Mako -, cheetah -, pygtk # Note: GR is migrating to Mako. Cheetah should be removed for GR3.8 -# => gr-wavelet: collection of wavelet blocks -, gsl -# => gr-qtgui: the Qt-based GUI -, qt4 -, qwt -, pyqt4 -# => gr-wxgui: the Wx-based GUI -, wxPython -, lxml -# => gr-audio: audio subsystems (system/OS dependent) -, alsaLib # linux 'audio-alsa' -, CoreAudio # darwin 'audio-osx' -# => uhd: the Ettus USRP Hardware Driver Interface +, codec2 +, gsm +, fftwFloat +, alsaLib +, libjack2 +, CoreAudio , uhd -# => gr-video-sdl: PAL and NTSC display , SDL -# Other -, libusb1 -, orc -, pyopengl +, gsl +, cppzmq +, zeromq +# GUI related +, gtk3 +, pango +, gobject-introspection +, cairo +, qt5 +, libsForQt5 +# Features available to override, the list of them is in featuresInfo. They +# are all turned on by default. +, features ? {} +# If one wishes to use a different src or name for a very custom build +, overrideSrc ? {} +, pname ? "gnuradio" +, versionAttr ? { + major = "3.8"; + minor = "2"; + patch = "0"; +} +# Should be false on the release after 3.8.2.0 +, fetchSubmodules ? true }: -stdenv.mkDerivation rec { - pname = "gnuradio"; - version = "3.7.14.0"; - - src = fetchFromGitHub { - owner = "gnuradio"; - repo = "gnuradio"; - rev = "v${version}"; - sha256 = "1nh4f9dmygprlbqybd3j1byg9fsr6065n140mvc4b0v8qqygmhrc"; - fetchSubmodules = true; +let + sourceSha256 = "1mnfwdy7w3160vi6110x2qkyq8l78qi8771zwak9n72bl7lhhpnf"; + featuresInfo = { + # Needed always + basic = { + native = [ + cmake + pkgconfig + orc + ]; + runtime = [ + boost + log4cpp + mpir + ]; + pythonNative = with python.pkgs; [ + Mako + six + ]; + }; + # NOTE: Should be removed on the release after 3.8.2.0, see: + # https://github.com/gnuradio/gnuradio/commit/80c04479d + volk = { + cmakeEnableFlag = "VOLK"; + }; + doxygen = { + native = [ doxygen ]; + cmakeEnableFlag = "DOXYGEN"; + }; + sphinx = { + pythonNative = with python.pkgs; [ sphinx ]; + cmakeEnableFlag = "SPHINX"; + }; + python-support = { + pythonRuntime = [ python.pkgs.six ]; + native = [ + swig + python + ]; + cmakeEnableFlag = "PYTHON"; + }; + testing-support = { + native = [ cppunit ]; + cmakeEnableFlag = "TESTING"; + }; + gnuradio-runtime = { + cmakeEnableFlag = "GNURADIO_RUNTIME"; + }; + gr-ctrlport = { + # Thrift support is not really working well, and even the patch they + # recommend applying on 0.9.2 won't apply. See: + # https://github.com/gnuradio/gnuradio/blob/v3.8.2.0/gnuradio-runtime/lib/controlport/thrift/README + cmakeEnableFlag = "GR_CTRLPORT"; + native = [ + swig + ]; + }; + gnuradio-companion = { + pythonRuntime = with python.pkgs; [ + pyyaml + Mako + numpy + pygobject3 + ]; + runtime = [ + gtk3 + pango + gobject-introspection + cairo + ]; + cmakeEnableFlag = "GRC"; + }; + gr-blocks = { + cmakeEnableFlag = "GR_BLOCKS"; + }; + gr-fec = { + cmakeEnableFlag = "GR_FEC"; + }; + gr-fft = { + runtime = [ fftwFloat ]; + cmakeEnableFlag = "GR_FFT"; + }; + gr-filter = { + runtime = [ fftwFloat ]; + cmakeEnableFlag = "GR_FILTER"; + }; + gr-analog = { + cmakeEnableFlag = "GR_ANALOG"; + }; + gr-digital = { + cmakeEnableFlag = "GR_DIGITAL"; + }; + gr-dtv = { + cmakeEnableFlag = "GR_DTV"; + }; + gr-audio = { + runtime = [] + ++ stdenv.lib.optionals stdenv.isLinux [ alsaLib libjack2 ] + ++ stdenv.lib.optionals stdenv.isDarwin [ CoreAudio ] + ; + cmakeEnableFlag = "GR_AUDIO"; + }; + gr-channels = { + cmakeEnableFlag = "GR_CHANNELS"; + }; + gr-qtgui = { + runtime = [ qt5.qtbase libsForQt5.qwt ]; + pythonRuntime = [ python.pkgs.pyqt5 ]; + cmakeEnableFlag = "GR_QTGUI"; + }; + gr-trellis = { + cmakeEnableFlag = "GR_TRELLIS"; + }; + gr-uhd = { + runtime = [ uhd ]; + cmakeEnableFlag = "GR_UHD"; + }; + gr-utils = { + cmakeEnableFlag = "GR_UTILS"; + }; + gr-modtool = { + pythonRuntime = with python.pkgs; [ + click + click-plugins + ]; + cmakeEnableFlag = "GR_MODTOOL"; + }; + gr-video-sdl = { + runtime = [ SDL ]; + cmakeEnableFlag = "GR_VIDEO_SDL"; + }; + gr-vocoder = { + runtime = [ codec2 gsm ]; + cmakeEnableFlag = "GR_VOCODER"; + }; + gr-wavelet = { + cmakeEnableFlag = "GR_WAVELET"; + runtime = [ gsl ]; + }; + gr-zeromq = { + runtime = [ cppzmq zeromq ]; + cmakeEnableFlag = "GR_ZEROMQ"; + }; }; + shared = (import ./shared.nix { + inherit + stdenv + python + removeReferencesTo + featuresInfo + features + versionAttr + sourceSha256 + overrideSrc + fetchFromGitHub + fetchSubmodules + ; + qt = qt5; + gtk = gtk3; + }); + inherit (shared) + version + src + hasFeature # function + nativeBuildInputs + buildInputs + disallowedReferences + stripDebugList + passthru + doCheck + dontWrapPythonPrograms + meta + ; + 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 + # order to build, see https://github.com/qradiolink/qradiolink/issues/67 + ++ stdenv.lib.optionals (hasFeature "gr-vocoder" features) [ + "-DLIBCODEC2_LIBRARIES=${codec2}/lib/libcodec2.so" + "-DLIBCODEC2_INCLUDE_DIRS=${codec2}/include" + "-DLIBCODEC2_HAS_FREEDV_API=ON" + "-DLIBGSM_LIBRARIES=${gsm}/lib/libgsm.so" + "-DLIBGSM_INCLUDE_DIRS=${gsm}/include/gsm" + ] + ; - nativeBuildInputs = [ - cmake - pkgconfig - git - makeWrapper - cppunit - orc - ]; - - buildInputs = [ - boost - fftw - python - swig2 - lxml - qt4 - qwt - SDL - libusb1 - uhd - gsl - ] ++ stdenv.lib.optionals stdenv.isLinux [ alsaLib ] - ++ stdenv.lib.optionals stdenv.isDarwin [ CoreAudio ]; - - propagatedBuildInputs = [ - Mako - cheetah - numpy - scipy - matplotlib - pyqt4 - pygtk - wxPython - pyopengl - ]; - - NIX_LDFLAGS = "-lpthread"; - - enableParallelBuilding = true; - - postPatch = '' - substituteInPlace \ - gr-fec/include/gnuradio/fec/polar_decoder_common.h \ - --replace BOOST_CONSTEXPR_OR_CONST const - ''; - - # Enables composition with nix-shell - grcSetupHook = writeText "grcSetupHook.sh" '' - addGRCBlocksPath() { - addToSearchPath GRC_BLOCKS_PATH $1/share/gnuradio/grc/blocks - } - addEnvHooks "$targetOffset" addGRCBlocksPath - ''; - - setupHook = [ grcSetupHook ]; - - # patch wxgui and pygtk check due to python importerror in a headless environment - # wxgtk gui will be removed in GR3.8 - # c++11 hack may not be necessary anymore + postInstall = shared.postInstall + # This is the only python reference worth removing, if needed (3.7 doesn't + # set that reference). + + stdenv.lib.optionalString (!hasFeature "python-support" features) '' + ${removeReferencesTo}/bin/remove-references-to -t ${python} $out/lib/cmake/gnuradio/GnuradioConfig.cmake + '' + ; preConfigure = '' - export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -Wno-unused-variable ${stdenv.lib.optionalString (!stdenv.isDarwin) "-std=c++11"}" - sed -i 's/.*wx\.version.*/set(WX_FOUND TRUE)/g' gr-wxgui/CMakeLists.txt - sed -i 's/.*pygtk_version.*/set(PYGTK_FOUND TRUE)/g' grc/CMakeLists.txt - find . -name "CMakeLists.txt" -exec sed -i '1iadd_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=c++11>)' "{}" ";" - ''; - - # Framework path needed for qwt6_qt4 but not qwt5 - cmakeFlags = - stdenv.lib.optionals stdenv.isDarwin [ "-DCMAKE_FRAMEWORK_PATH=${qwt}/lib" ]; - - # - Ensure we get an interactive backend for matplotlib. If not the gr_plot_* - # programs will not display anything. Yes, $MATPLOTLIBRC must point to the - # *dirname* where matplotlibrc is located, not the file itself. - # - GNU Radio core is C++ but the user interface (GUI and API) is Python, so - # we must wrap the stuff in bin/. - # Notes: - # - May want to use makeWrapper instead of wrapProgram - # - may want to change interpreter path on Python examples instead of wrapping - # - see https://github.com/NixOS/nixpkgs/issues/22688 regarding use of --prefix / python.withPackages - # - see https://github.com/NixOS/nixpkgs/issues/24693 regarding use of DYLD_FRAMEWORK_PATH on Darwin - postInstall = '' - printf "backend : Qt4Agg\n" > "$out/share/gnuradio/matplotlibrc" - - for file in $(find $out/bin $out/share/gnuradio/examples -type f -executable); do - wrapProgram "$file" \ - --prefix PYTHONPATH : $PYTHONPATH:$(toPythonPath "$out") \ - --set MATPLOTLIBRC "$out/share/gnuradio" \ - ${stdenv.lib.optionalString stdenv.isDarwin "--set DYLD_FRAMEWORK_PATH /System/Library/Frameworks"} - done - ''; + '' + # If python-support is disabled, don't install volk's (git submodule) + # volk_modtool - it references python. + # + # NOTE: on the next release, volk will always be required to be installed + # externally (submodule removed upstream). Hence this hook will fail and + # we'll need to package volk while able to tell it to install or not + # install python referencing files. When we'll be there, this will help: + # https://github.com/gnuradio/volk/pull/404 + + stdenv.lib.optionalString (!hasFeature "python-support" features) '' + sed -i -e "/python\/volk_modtool/d" volk/CMakeLists.txt + '' + ; + patches = [ + # Don't install python referencing files if python support is disabled. + # See: https://github.com/gnuradio/gnuradio/pull/3839 + (fetchpatch { + url = "https://github.com/gnuradio/gnuradio/commit/4a4fd570b398b0b50fe875fcf0eb9c9db2ea5c6e.diff"; + sha256 = "xz2E0ji6zfdOAhjfPecAcaVOIls1XP8JngLkBbBBW5Q="; + }) + (fetchpatch { + url = "https://github.com/gnuradio/gnuradio/commit/dbc8ad7e7361fddc7b1dbc267c07a776a3f9664b.diff"; + sha256 = "tQcCpcUbJv3yqAX8rSHN/pAuBq4ueEvoVo7sNzZGvf4="; + }) + ]; +in - meta = with stdenv.lib; { - description = "Software Defined Radio (SDR) software"; - longDescription = '' - GNU Radio is a free & open-source software development toolkit that - provides signal processing blocks to implement software radios. It can be - used with readily-available low-cost external RF hardware to create - software-defined radios, or without hardware in a simulation-like - environment. It is widely used in hobbyist, academic and commercial - environments to support both wireless communications research and - real-world radio systems. - ''; - homepage = "https://www.gnuradio.org"; - license = licenses.gpl3; - platforms = platforms.linux ++ platforms.darwin; - maintainers = with maintainers; [ bjornfor fpletz ]; - }; +stdenv.mkDerivation rec { + inherit + pname + version + src + nativeBuildInputs + buildInputs + cmakeFlags + preConfigure + # disallowedReferences + stripDebugList + patches + postInstall + passthru + doCheck + dontWrapPythonPrograms + meta + ; } |