From 2d08e55e9b8f96cf00466bd55fe0d132f1abd008 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 16 Oct 2020 23:31:20 +0300 Subject: [PATCH] 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 --- nixos/doc/manual/release-notes/rl-2105.xml | 12 +- pkgs/applications/radio/gnuradio/3.7.nix | 8 +- pkgs/applications/radio/gnuradio/ais.nix | 53 -------- pkgs/applications/radio/gnuradio/default.nix | 8 ++ pkgs/applications/radio/gnuradio/gsm.nix | 37 ----- pkgs/applications/radio/gnuradio/limesdr.nix | 38 ------ pkgs/applications/radio/gnuradio/osmosdr.nix | 45 ------- pkgs/applications/radio/gnuradio/rds.nix | 36 ----- pkgs/applications/radio/gnuradio/wrapper.nix | 125 +++++++++++------ .../applications/radio/qradiolink/default.nix | 32 +++-- .../gnuradio-modules/ais/default.nix | 45 +++++++ .../gnuradio-modules/gsm/default.nix | 48 +++++++ .../gnuradio-modules/limesdr/default.nix | 59 ++++++++ .../gnuradio-modules/mkDerivation.nix | 23 ++++ .../gnuradio-modules/nacl/default.nix} | 41 +++--- .../gnuradio-modules/osmosdr/default.nix | 84 ++++++++++++ .../gnuradio-modules/rds/default.nix | 57 ++++++++ pkgs/top-level/aliases.nix | 24 ++-- pkgs/top-level/all-packages.nix | 127 +++++++----------- pkgs/top-level/gnuradio-packages.nix | 46 +++++++ 20 files changed, 581 insertions(+), 367 deletions(-) delete mode 100644 pkgs/applications/radio/gnuradio/ais.nix delete mode 100644 pkgs/applications/radio/gnuradio/gsm.nix delete mode 100644 pkgs/applications/radio/gnuradio/limesdr.nix delete mode 100644 pkgs/applications/radio/gnuradio/osmosdr.nix delete mode 100644 pkgs/applications/radio/gnuradio/rds.nix create mode 100644 pkgs/development/gnuradio-modules/ais/default.nix create mode 100644 pkgs/development/gnuradio-modules/gsm/default.nix create mode 100644 pkgs/development/gnuradio-modules/limesdr/default.nix create mode 100644 pkgs/development/gnuradio-modules/mkDerivation.nix rename pkgs/{applications/radio/gnuradio/nacl.nix => development/gnuradio-modules/nacl/default.nix} (50%) create mode 100644 pkgs/development/gnuradio-modules/osmosdr/default.nix create mode 100644 pkgs/development/gnuradio-modules/rds/default.nix create mode 100644 pkgs/top-level/gnuradio-packages.nix diff --git a/nixos/doc/manual/release-notes/rl-2105.xml b/nixos/doc/manual/release-notes/rl-2105.xml index e052632ecaf..b091bdb3e27 100644 --- a/nixos/doc/manual/release-notes/rl-2105.xml +++ b/nixos/doc/manual/release-notes/rl-2105.xml @@ -36,7 +36,17 @@ now point to an externally wrapped by default derivations, that allow you to also add `extraPythonPackages` to the Python interpreter used by GNURadio. Missing environmental variables needed for operational GUI were also added - (#7547). + (#75478). + + + + + GNURadio has a + pkgs attribute set, and there's a gnuradio.callPackage + function that extends pkgs with a mkDerivation, and a + mkDerivationWith, like Qt5. Now all gnuradio.pkgs are + defined with gnuradio.callPackage and some packages that depend + on gnuradio are defined with this as well. diff --git a/pkgs/applications/radio/gnuradio/3.7.nix b/pkgs/applications/radio/gnuradio/3.7.nix index a48efb9aa6d..7ad2d297982 100644 --- a/pkgs/applications/radio/gnuradio/3.7.nix +++ b/pkgs/applications/radio/gnuradio/3.7.nix @@ -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 diff --git a/pkgs/applications/radio/gnuradio/ais.nix b/pkgs/applications/radio/gnuradio/ais.nix deleted file mode 100644 index 8d6e8509772..00000000000 --- a/pkgs/applications/radio/gnuradio/ais.nix +++ /dev/null @@ -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 ]; - }; -} diff --git a/pkgs/applications/radio/gnuradio/default.nix b/pkgs/applications/radio/gnuradio/default.nix index f8fc1fa10f8..fc7890299c5 100644 --- a/pkgs/applications/radio/gnuradio/default.nix +++ b/pkgs/applications/radio/gnuradio/default.nix @@ -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 diff --git a/pkgs/applications/radio/gnuradio/gsm.nix b/pkgs/applications/radio/gnuradio/gsm.nix deleted file mode 100644 index 28c5045081b..00000000000 --- a/pkgs/applications/radio/gnuradio/gsm.nix +++ /dev/null @@ -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 ]; - }; -} diff --git a/pkgs/applications/radio/gnuradio/limesdr.nix b/pkgs/applications/radio/gnuradio/limesdr.nix deleted file mode 100644 index afe3de64527..00000000000 --- a/pkgs/applications/radio/gnuradio/limesdr.nix +++ /dev/null @@ -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 ]; - }; -} diff --git a/pkgs/applications/radio/gnuradio/osmosdr.nix b/pkgs/applications/radio/gnuradio/osmosdr.nix deleted file mode 100644 index 436c4309a5b..00000000000 --- a/pkgs/applications/radio/gnuradio/osmosdr.nix +++ /dev/null @@ -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 ]; - }; -} diff --git a/pkgs/applications/radio/gnuradio/rds.nix b/pkgs/applications/radio/gnuradio/rds.nix deleted file mode 100644 index 4f15f2a961e..00000000000 --- a/pkgs/applications/radio/gnuradio/rds.nix +++ /dev/null @@ -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 ]; - }; -} diff --git a/pkgs/applications/radio/gnuradio/wrapper.nix b/pkgs/applications/radio/gnuradio/wrapper.nix index aaf74abc2c5..d255b199bc9 100644 --- a/pkgs/applications/radio/gnuradio/wrapper.nix +++ b/pkgs/applications/radio/gnuradio/wrapper.nix @@ -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 diff --git a/pkgs/applications/radio/qradiolink/default.nix b/pkgs/applications/radio/qradiolink/default.nix index 24c5f987f17..1688d0010fe 100644 --- a/pkgs/applications/radio/qradiolink/default.nix +++ b/pkgs/applications/radio/qradiolink/default.nix @@ -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; diff --git a/pkgs/development/gnuradio-modules/ais/default.nix b/pkgs/development/gnuradio-modules/ais/default.nix new file mode 100644 index 00000000000..0770d83f21d --- /dev/null +++ b/pkgs/development/gnuradio-modules/ais/default.nix @@ -0,0 +1,45 @@ +{ lib +, stdenv +, mkDerivation +, fetchFromGitHub +, cmake +, pkg-config +, python +, boost +, cppunit +, log4cpp +, osmosdr +}: + +mkDerivation rec { + pname = "gr-ais"; + version = "2015-12-20"; + src = fetchFromGitHub { + owner = "bistromath"; + repo = "gr-ais"; + rev = "cdc1f52745853f9c739c718251830eb69704b26e"; + sha256 = "1vl3kk8xr2mh5lf31zdld7yzmwywqffffah8iblxdzblgsdwxfl6"; + }; + disabledForGRafter = "3.8"; + + nativeBuildInputs = [ + cmake + pkg-config + python + ]; + + buildInputs = [ + cppunit + osmosdr + boost + log4cpp + ]; + + meta = with lib; { + description = "Gnuradio block for ais"; + homepage = "https://github.com/bistromath/gr-ais"; + license = licenses.gpl3Plus; + platforms = platforms.unix; + maintainers = with maintainers; [ mog ]; + }; +} diff --git a/pkgs/development/gnuradio-modules/gsm/default.nix b/pkgs/development/gnuradio-modules/gsm/default.nix new file mode 100644 index 00000000000..835c5456668 --- /dev/null +++ b/pkgs/development/gnuradio-modules/gsm/default.nix @@ -0,0 +1,48 @@ +{ lib +, mkDerivation +, fetchFromGitHub +, cmake +, pkg-config +, cppunit +, swig +, boost +, log4cpp +, python +, libosmocore +, osmosdr +}: + +mkDerivation { + pname = "gr-gsm"; + version = "2016-08-25"; + src = fetchFromGitHub { + owner = "ptrkrysik"; + repo = "gr-gsm"; + rev = "3ca05e6914ef29eb536da5dbec323701fbc2050d"; + sha256 = "13nnq927kpf91iqccr8db9ripy5czjl5jiyivizn6bia0bam2pvx"; + }; + disabledForGRafter = "3.8"; + + nativeBuildInputs = [ + cmake + pkg-config + swig + python + ]; + + buildInputs = [ + cppunit + log4cpp + boost + libosmocore + osmosdr + ]; + + 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 ]; + }; +} diff --git a/pkgs/development/gnuradio-modules/limesdr/default.nix b/pkgs/development/gnuradio-modules/limesdr/default.nix new file mode 100644 index 00000000000..63136b33d65 --- /dev/null +++ b/pkgs/development/gnuradio-modules/limesdr/default.nix @@ -0,0 +1,59 @@ +{ lib +, mkDerivation +, fetchFromGitHub +, gnuradio +, cmake +, pkg-config +, doxygen +, swig +, python +, log4cpp +, mpir +, boost +, gmp +, icu +, limesuite +}: + +let + version = { + "3.7" = "2.0.0"; + "3.8" = "3.0.1"; + }.${gnuradio.versionAttr.major}; + src = fetchFromGitHub { + owner = "myriadrf"; + repo = "gr-limesdr"; + rev = "v${version}"; + sha256 = { + "3.7" = "0ldqvfwl0gil89l9s31fjf9d7ki0dk572i8vna336igfaz348ypq"; + "3.8" = "ffs+8TU0yr6IW1xZJ/abQ1CQWGZM+zYqPRJxy3ZvM9U="; + }.${gnuradio.versionAttr.major}; + }; +in mkDerivation { + pname = "gr-limesdr"; + inherit version src; + disabledForGRafter = "3.9"; + + nativeBuildInputs = [ + cmake + pkg-config + swig + python + ]; + buildInputs = [ + log4cpp + mpir + boost + gmp + icu + limesuite + ]; + + 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 ]; + }; +} diff --git a/pkgs/development/gnuradio-modules/mkDerivation.nix b/pkgs/development/gnuradio-modules/mkDerivation.nix new file mode 100644 index 00000000000..235eff25cdb --- /dev/null +++ b/pkgs/development/gnuradio-modules/mkDerivation.nix @@ -0,0 +1,23 @@ +{ lib +, unwrapped +}: + +mkDerivation: + +args: + +# Check if it's supposed to not get built for the current gnuradio version +if (builtins.hasAttr "disabledForGRafter" args) && +(lib.versionAtLeast unwrapped.versionAttr.major args.disabledForGRafter) then +let name = args.name or "${args.pname}"; in +throw "Package ${name} is incompatible with GNURadio ${unwrapped.versionAttr.major}" +else + +let + args_ = { + enableParallelBuilding = args.enableParallelBuilding or true; + nativeBuildInputs = (args.nativeBuildInputs or []); + # We add gnuradio itself by default + buildInputs = (args.buildInputs or []) ++ [ unwrapped ]; + }; +in mkDerivation (args // args_) diff --git a/pkgs/applications/radio/gnuradio/nacl.nix b/pkgs/development/gnuradio-modules/nacl/default.nix similarity index 50% rename from pkgs/applications/radio/gnuradio/nacl.nix rename to pkgs/development/gnuradio-modules/nacl/default.nix index f6c21e79454..1ffb0afee07 100644 --- a/pkgs/applications/radio/gnuradio/nacl.nix +++ b/pkgs/development/gnuradio-modules/nacl/default.nix @@ -1,31 +1,40 @@ -{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, boost, gnuradio, uhd -, makeWrapper, libsodium, cppunit, log4cpp -, pythonSupport ? true, python, swig +{ lib +, mkDerivation +, fetchFromGitHub +, cmake +, pkg-config +, cppunit +, swig +, boost +, log4cpp +, python +, libsodium }: -assert pythonSupport -> python != null && swig != null; - -stdenv.mkDerivation { +mkDerivation { pname = "gr-nacl"; version = "2017-04-10"; - src = fetchFromGitHub { owner = "stwunsch"; repo = "gr-nacl"; rev = "15276bb0fcabf5fe4de4e58df3d579b5be0e9765"; sha256 = "018np0qlk61l7mlv3xxx5cj1rax8f1vqrsrch3higsl25yydbv7v"; }; + disabledForGRafter = "3.8"; + + nativeBuildInputs = [ + cmake + pkg-config + swig + python + ]; - 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 - ''; + cppunit + log4cpp + boost + libsodium + ]; meta = with lib; { description = "Gnuradio block for encryption"; diff --git a/pkgs/development/gnuradio-modules/osmosdr/default.nix b/pkgs/development/gnuradio-modules/osmosdr/default.nix new file mode 100644 index 00000000000..4159862bbed --- /dev/null +++ b/pkgs/development/gnuradio-modules/osmosdr/default.nix @@ -0,0 +1,84 @@ +{ lib +, mkDerivation +, fetchgit +, gnuradio +, cmake +, pkg-config +, log4cpp +, mpir +, boost +, gmp +, fftwFloat +, python +, swig +, uhd +, icu +, airspy +, hackrf +, libbladeRF +, rtl-sdr +, soapysdr-with-plugins +}: + +let + version = { + "3.7" = "0.1.5"; + "3.8" = "0.2.2"; + }.${gnuradio.versionAttr.major}; + src = fetchgit { + url = "git://git.osmocom.org/gr-osmosdr"; + rev = "v${version}"; + sha256 = { + "3.7" = "0bf9bnc1c3c4yqqqgmg3nhygj6rcfmyk6pybi27f7461d2cw1drv"; + "3.8" = "HT6xlN6cJAnvF+s1g2I1uENhBJJizdADlLXeSD0rEqs="; + }.${gnuradio.versionAttr.major}; + }; +in mkDerivation { + pname = "gr-osmosdr"; + inherit version src; + disabledForGRafter = "3.9"; + + buildInputs = [ + log4cpp + mpir + boost + fftwFloat + gmp + icu + airspy + hackrf + libbladeRF + rtl-sdr + soapysdr-with-plugins + ] ++ lib.optional (gnuradio.hasFeature "gr-uhd" gnuradio.features) [ + uhd + ]; + cmakeFlags = [ + (if (gnuradio.hasFeature "python-support" gnuradio.features) then + "-DENABLE_PYTHON=ON" + else + "-DENABLE_PYTHON=OFF" + ) + ]; + nativeBuildInputs = [ + cmake + pkg-config + swig + ] ++ lib.optionals (gnuradio.hasFeature "python-support" gnuradio.features) [ + (if (gnuradio.versionAttr.major == "3.7") then + python.pkgs.cheetah + else + python.pkgs.Mako + ) + python + ] + ; + + meta = with lib; { + description = "Gnuradio block for OsmoSDR and rtl-sdr"; + homepage = "https://sdr.osmocom.org/trac/wiki/GrOsmoSDR"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ bjornfor ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/development/gnuradio-modules/rds/default.nix b/pkgs/development/gnuradio-modules/rds/default.nix new file mode 100644 index 00000000000..a2062783bd7 --- /dev/null +++ b/pkgs/development/gnuradio-modules/rds/default.nix @@ -0,0 +1,57 @@ +{ lib +, mkDerivation +, fetchFromGitHub +, gnuradio +, cmake +, pkg-config +, swig +, python +, log4cpp +, mpir +, boost +, gmp +, icu +}: + +let + version = { + "3.7" = "1.1.0"; + "3.8" = "3.8.0"; + }.${gnuradio.versionAttr.major}; + src = fetchFromGitHub { + owner = "bastibl"; + repo = "gr-rds"; + rev = "v${version}"; + sha256 = { + "3.7" = "0jkzchvw0ivcxsjhi1h0mf7k13araxf5m4wi5v9xdgqxvipjzqfy"; + "3.8" = "+yKLJu2bo7I2jkAiOdjvdhZwxFz9NFgTmzcLthH9Y5o="; + }.${gnuradio.versionAttr.major}; + }; +in mkDerivation { + pname = "gr-rds"; + inherit version src; + disabledForGRafter = "3.9"; + + buildInputs = [ + log4cpp + mpir + boost + gmp + icu + ]; + + nativeBuildInputs = [ + cmake + pkg-config + swig + python + ]; + + meta = with lib; { + description = "Gnuradio block for radio data system"; + homepage = "https://github.com/bastibl/gr-rds"; + license = licenses.gpl2Plus; + platforms = platforms.unix; + maintainers = with maintainers; [ mog ]; + }; +} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 6036e421683..260c5cfb2bc 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -240,16 +240,24 @@ mapAliases ({ gnome_doc_utils = gnome-doc-utils; # added 2018-02-25 gnome_themes_standard = gnome-themes-standard; # added 2018-02-25 gnunet_git = throw "gnunet_git was removed due to gnunet becoming stable"; # added 2019-05-27 - gnuradio-nacl = gr-nacl; # added 2019-05-27 - gnuradio-gsm = gr-gsm; # added 2019-05-27 - gnuradio-ais = gr-ais; # added 2019-05-27 - gnuradio-limesdr = gr-limesdr; # added 2019-05-27 - gnuradio-rds = gr-rds; # added 2019-05-27 - gnuradio-osmosdr = gr-osmosdr; # added 2019-05-27 - # added 20-10-2020 + # Added 2020-10-16 gnuradio-with-packages = gnuradio3_7.override { - extraPackages = [ gr-nacl gr-gsm gr-ais gr-limesdr gr-rds gr-osmosdr ]; + extraPackages = lib.attrVals [ + "osmosdr" "ais" "gsm" "nacl" "rds" "limesdr" + ] gnuradio3_7Packages; }; + gnuradio-nacl = gnuradio3_7.pkgs.nacl; # added 2019-05-27, changed 2020-10-16 + gnuradio-gsm = gnuradio3_7.pkgs.gsm; # added 2019-05-27, changed 2020-10-16 + gnuradio-ais = gnuradio3_7.pkgs.ais; # added 2019-05-27, changed 2020-10-16 + gnuradio-limesdr = gnuradio3_7.pkgs.limesdr; # added 2019-05-27, changed 2020-10-16 + gnuradio-rds = gnuradio3_7.pkgs.rds; # added 2019-05-27, changed 2020-10-16 + gnuradio-osmosdr = gnuradio3_7.pkgs.osmosdr; # added 2019-05-27, changed 2020-10-16 + gr-nacl = gnuradio3_7.pkgs.nacl; # added 2019-05-27, changed 2020-10-16 + gr-gsm = gnuradio3_7.pkgs.gsm; # added 2019-05-27, changed 2020-10-16 + gr-ais = gnuradio3_7.pkgs.ais; # added 2019-05-27, changed 2020-10-16 + gr-limesdr = gnuradio3_7.pkgs.limesdr; # added 2019-05-27, changed 2020-10-16 + gr-rds = gnuradio3_7.pkgs.rds; # added 2019-05-27, changed 2020-10-16 + gr-osmosdr = gnuradio3_7.pkgs.osmosdr; # added 2019-05-27, changed 2020-10-16 gnustep-make = gnustep.make; # added 2016-7-6 gnupg20 = throw "gnupg20 has been removed from nixpkgs as upstream dropped support on 2017-12-31";# added 2020-07-12 gnuvd = throw "gnuvd was removed because the backend service is missing"; # added 2020-01-14 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 97da2fa1699..4a6fe9410cc 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16776,13 +16776,7 @@ in qm-dsp = callPackage ../development/libraries/audio/qm-dsp { }; - qradiolink = callPackage ../applications/radio/qradiolink { - # 3.8 support is not ready yet: - # https://github.com/qradiolink/qradiolink/issues/67#issuecomment-703222573 - # The non minimal build is used because the 'qtgui' component is needed. - # gr-osmosdr is using the same gnuradio as of now. - gnuradio = gnuradio3_7-unwrapped; - }; + qradiolink = callPackage ../applications/radio/qradiolink { }; qrupdate = callPackage ../development/libraries/qrupdate { }; @@ -22333,82 +22327,62 @@ in gnss-sdr = callPackage ../applications/radio/gnss-sdr { boost = boost166; - gnuradio = gnuradio3_7-unwrapped; + gnuradio = gnuradio3_7.unwrapped; }; - gnuradio-unwrapped = callPackage ../applications/radio/gnuradio { - inherit (darwin.apple_sdk.frameworks) CoreAudio; - python = python3; - boost = boost17x; - }; - # A build without gui components and other utilites not needed for end user - # libraries - gnuradioMinimal = gnuradio-unwrapped.override { - features = { - gnuradio-companion = false; - python-support = false; - gr-ctrlport = false; - examples = false; - gr-qtgui = false; - gr-utils = false; - gr-modtool = false; - sphinx = false; - doxygen = false; + gnuradio = callPackage ../applications/radio/gnuradio/wrapper.nix { + unwrapped = callPackage ../applications/radio/gnuradio { + inherit (darwin.apple_sdk.frameworks) CoreAudio; + python = python3; + boost = boost17x; }; }; - gnuradio = callPackage ../applications/radio/gnuradio/wrapper.nix { - unwrapped = gnuradio-unwrapped; - }; - gnuradio3_7-unwrapped = callPackage ../applications/radio/gnuradio/3.7.nix { - inherit (darwin.apple_sdk.frameworks) CoreAudio; - python = python2; - # Incompatible with uhd4+ - uhd = uhd3_5; - }; - # A build without gui components and other utilites not needed if gnuradio is - # used as a c++ library. - gnuradio3_7Minimal = gnuradio3_7-unwrapped.override { - features = { - gnuradio-companion = false; - python-support = false; - gr-ctrlport = false; - gr-qtgui = false; - gr-utils = false; - sphinx = false; - doxygen = false; - gr-wxgui = false; + gnuradioPackages = lib.recurseIntoAttrs gnuradio.pkgs; + # A build without gui components and other utilites not needed for end user + # libraries + gnuradioMinimal = gnuradio.override { + wrap = false; + unwrapped = gnuradio.unwrapped.override { + features = { + gnuradio-companion = false; + python-support = false; + examples = false; + gr-qtgui = false; + gr-utils = false; + gr-modtool = false; + sphinx = false; + doxygen = false; + }; }; }; gnuradio3_7 = callPackage ../applications/radio/gnuradio/wrapper.nix { - unwrapped = gnuradio3_7-unwrapped; + unwrapped = callPackage ../applications/radio/gnuradio/3.7.nix { + inherit (darwin.apple_sdk.frameworks) CoreAudio; + python = python2; + # Incompatible with uhd4+ + uhd = uhd3_5; + }; + }; + gnuradio3_7Packages = lib.recurseIntoAttrs gnuradio3_7.pkgs; + # A build without gui components and other utilites not needed if gnuradio is + # used as a c++ library. + gnuradio3_7Minimal = gnuradio3_7.override { + wrap = false; + unwrapped = gnuradio3_7.unwrapped.override { + features = { + gnuradio-companion = false; + python-support = false; + gr-qtgui = false; + gr-utils = false; + sphinx = false; + doxygen = false; + gr-wxgui = false; + }; + }; }; grandorgue = callPackage ../applications/audio/grandorgue { }; - gr-nacl = callPackage ../applications/radio/gnuradio/nacl.nix { - gnuradio = gnuradio3_7-unwrapped; - }; - - gr-gsm = callPackage ../applications/radio/gnuradio/gsm.nix { - gnuradio = gnuradio3_7-unwrapped; - }; - - gr-ais = callPackage ../applications/radio/gnuradio/ais.nix { - gnuradio = gnuradio3_7-unwrapped; - }; - - gr-limesdr = callPackage ../applications/radio/gnuradio/limesdr.nix { - gnuradio = gnuradio3_7-unwrapped; - }; - - gr-rds = callPackage ../applications/radio/gnuradio/rds.nix { - gnuradio = gnuradio3_7-unwrapped; - }; - - gr-osmosdr = callPackage ../applications/radio/gnuradio/osmosdr.nix { - gnuradio = gnuradio3_7-unwrapped; - }; - goldendict = libsForQt5.callPackage ../applications/misc/goldendict { inherit (darwin) libiconv; }; @@ -22435,14 +22409,7 @@ in gpx = callPackage ../applications/misc/gpx { }; - gqrx = libsForQt514.callPackage ../applications/radio/gqrx { - gnuradio = gnuradio3_7Minimal; - # Use the same gnuradio for gr-osmosdr as well - gr-osmosdr = gr-osmosdr.override { - gnuradio = gnuradio3_7Minimal; - pythonSupport = false; - }; - }; + gqrx = callPackage ../applications/radio/gqrx { }; gpx-viewer = callPackage ../applications/misc/gpx-viewer { }; diff --git a/pkgs/top-level/gnuradio-packages.nix b/pkgs/top-level/gnuradio-packages.nix new file mode 100644 index 00000000000..6c8db76cb3e --- /dev/null +++ b/pkgs/top-level/gnuradio-packages.nix @@ -0,0 +1,46 @@ +{ lib +, stdenv +, newScope +, gnuradio # unwrapped gnuradio +}: + +lib.makeScope newScope ( self: + +let + # Modeled after qt's + mkDerivationWith = import ../development/gnuradio-modules/mkDerivation.nix { + inherit lib; + unwrapped = gnuradio; + }; + mkDerivation = mkDerivationWith stdenv.mkDerivation; + + callPackage = self.newScope { + inherit (gnuradio) + # Packages that are potentially overriden and commonly + boost + uhd + ; + inherit mkDerivationWith mkDerivation; + }; + +in { + + inherit callPackage mkDerivation mkDerivationWith; + + ### Packages + + inherit gnuradio; + + osmosdr = callPackage ../development/gnuradio-modules/osmosdr/default.nix { }; + + ais = callPackage ../development/gnuradio-modules/ais/default.nix { }; + + gsm = callPackage ../development/gnuradio-modules/gsm/default.nix { }; + + nacl = callPackage ../development/gnuradio-modules/nacl/default.nix { }; + + rds = callPackage ../development/gnuradio-modules/rds/default.nix { }; + + limesdr = callPackage ../development/gnuradio-modules/limesdr/default.nix { }; + +})