Subject: [PATCH] gnu: adds hackrf

From: Christopher Howard <[email-masked]>
Date: Sun, 26 Apr 2020 03:06:18 -0800

I have asked many times about the new release over the last few months,
and each time hackrf team says it is a week or so away. But their last
git commit was in February. Requesting to please proceed with the
latest commit as represented in this patch. I have added information to
the description as requested.

Using the old 2018 release would be unsatisfactory due to an annoying
bug related to maintaining connections to hackrf devices.

As an additional motivation for adding this, I believe you need
libhackrf installed to use hackrf with gnuradio, through the osmocom
interface. (I'm not at the moment quite clear on what exactly you have
to enable in the gnuradio package definitions to link those together.)
E.g., https://packages.debian.org/stretch/gr-osmosdr

-- 
Christopher Howard
p: +1 (907) 374-0257
w: https://librehacker.com
social: https://gnusocial.club/librehacker
gpg: ADDEAADE5D607C8D (keys.gnupg.net)
From 7567d155fd3922fe27a3aaa3d155dc4f9db0a329 Mon Sep 17 00:00:00 2001
From: Christopher Howard <[email-masked]>
Date: Sun, 26 Apr 2020 02:52:48 -0800
Subject: [PATCH] gnu: adds hackrf

---
 gnu/packages/radio.scm | 57 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/gnu/packages/radio.scm b/gnu/packages/radio.scm
index fff68cf657..91908d47b5 100644
--- a/gnu/packages/radio.scm
+++ b/gnu/packages/radio.scm
@@ -654,6 +654,63 @@ for correctness.")
     (home-page "http://www.w1hkj.com/")
     (license license:gpl3+)))
 
+(define-public hackrf
+  ;; Using a git commit because there have been many many commits
+  ;; since the relase two years ago, but no sign of a promised
+  ;; release for many months now.
+  (let ((commit "43e6f99fe8543094d18ff3a6550ed2066c398862")
+        (revision "0"))
+    (package
+     (name "hackrf")
+     (version (git-version "2018.01.1" revision commit))
+     (source
+      (origin (method git-fetch)
+	      (uri (git-reference
+		    (url "https://github.com/mossmann/hackrf.git")
+		    (commit commit)))
+	      (file-name (git-file-name name version))
+	      (sha256
+	       (base32 "0avnv693xi0zsnrvkbfn0ln1r3s1iyj0bz7sc3gxay909av0pvbc"))))
+     (build-system cmake-build-system)
+     (arguments
+      '(#:configure-flags
+        (list "-DUDEV_RULES_GROUP=dialout"
+	      (string-append "-DUDEV_RULES_PATH="
+                             (assoc-ref %outputs "out")
+			     "/lib/udev/rules.d"))
+        #:phases
+	(modify-phases %standard-phases
+	  (add-before 'configure 'enter-source-directory
+		      (lambda _ (chdir "host") #t))
+	  (add-before 'install-license-files 'leave-source-directory
+		      (lambda _ (chdir "..") #t)))
+        #:tests? #f))                  ; no test suite
+     (native-inputs
+      `(("pkg-config" ,pkg-config)))
+     (inputs
+      `(("fftw" ,fftw)
+        ("fftwf" ,fftwf)
+	("libusb" ,libusb)))
+     (home-page "https://greatscottgadgets.com/hackrf/")
+     (synopsis "User-space library and utilities for HackRF SDR")
+     (description
+      "Command line utilities and a C library for controlling the HackRF
+Software Defined Radio (SDR) over USB.  Installing this package installs
+the userspace hackrf utilities and C library.  To install the hackrf
+udev rules, you must add this package as a system service via
+modify-services.  E.g.:
+
+@lisp
+(services
+ (modify-services
+  %desktop-services
+  (udev-service-type config =>
+   (udev-configuration (inherit config)
+    (rules (cons hackrf
+            (udev-configuration-rules config)))))))
+@end lisp")
+     (license license:gpl2))))
+
 (define-public hamlib
   (package
     (name "hamlib")
-- 
2.26.2