From 25b822db3786ad3f59e27db679c521ce6cd29b81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <bjorn.forsman@gmail.com>
Date: Thu, 2 May 2013 12:44:36 +0200
Subject: [PATCH] gnuradio: new package

Add GNU Radio, the free & open-source software development toolkit that
provides signal processing blocks to implement software radios.
---
 pkgs/applications/misc/gnuradio/default.nix | 76 +++++++++++++++++++++
 pkgs/top-level/all-packages.nix             |  5 ++
 2 files changed, 81 insertions(+)
 create mode 100644 pkgs/applications/misc/gnuradio/default.nix

diff --git a/pkgs/applications/misc/gnuradio/default.nix b/pkgs/applications/misc/gnuradio/default.nix
new file mode 100644
index 000000000000..3c47e3bf8a82
--- /dev/null
+++ b/pkgs/applications/misc/gnuradio/default.nix
@@ -0,0 +1,76 @@
+{ stdenv, fetchurl
+# core dependencies
+, cmake, pkgconfig, git, boost, cppunit, fftw
+# python wrappers
+, python, swig2, numpy, scipy, matplotlib
+# grc - the gnu radio companion
+, cheetahTemplate, pygtk
+# gr-wavelet: collection of wavelet blocks
+, gsl
+# gr-qtgui: the Qt-based GUI
+, qt4, qwt, pyqt4 #, pyqwt
+# gr-wxgui: the Wx-based GUI
+, wxPython, lxml
+# gr-audio: audio subsystems (system/OS dependent)
+, alsaLib
+# uhd: the Ettus USRP Hardware Driver Interface
+, uhd
+# gr-video-sdl: PAL and NTSC display
+, SDL
+, libusb1, orc, pyopengl
+, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "gnuradio-${version}";
+  version = "3.7.1";
+
+  src = fetchurl {
+    url = "http://gnuradio.org/releases/gnuradio/${name}.tar.gz";
+    sha256 = "1kfni8vpgr6v9rdiz3zsmwc07qj6zka9x22z2y0y4rak2xnzdxz9";
+  };
+
+  buildInputs = [
+    cmake pkgconfig git boost cppunit fftw python swig2 orc lxml qt4 qwt
+    alsaLib SDL libusb1 uhd gsl makeWrapper
+  ];
+
+  propagatedBuildInputs = [
+    cheetahTemplate numpy scipy matplotlib pyqt4 pygtk wxPython pyopengl
+  ];
+
+  preConfigure = ''
+    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -Wno-unused-variable"
+  '';
+
+  # - 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/.
+  postInstall = ''
+    printf "backend : Qt4Agg\n" > "$out/share/gnuradio/matplotlibrc"
+
+    for file in "$out"/bin/*; do
+        wrapProgram "$file" \
+            --set PYTHONPATH $PYTHONPATH:$(toPythonPath "$out") \
+            --set MATPLOTLIBRC "$out/share/gnuradio"
+    done
+  '';
+
+  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 = http://www.gnuradio.org;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index efe0bff707c5..f462c62b4f20 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -7779,6 +7779,11 @@ let
 
   geany = callPackage ../applications/editors/geany { };
 
+  gnuradio = callPackage ../applications/misc/gnuradio {
+    inherit (pythonPackages) lxml numpy scipy matplotlib pyopengl;
+    fftw = fftwFloat;
+  };
+
   goldendict = callPackage ../applications/misc/goldendict { };
 
   google-musicmanager = callPackage ../applications/audio/google-musicmanager { };