summary refs log tree commit diff
path: root/pkgs/applications/radio/uhd/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/radio/uhd/default.nix')
-rw-r--r--pkgs/applications/radio/uhd/default.nix40
1 files changed, 31 insertions, 9 deletions
diff --git a/pkgs/applications/radio/uhd/default.nix b/pkgs/applications/radio/uhd/default.nix
index 23c0a728586..c3f7b58fa1b 100644
--- a/pkgs/applications/radio/uhd/default.nix
+++ b/pkgs/applications/radio/uhd/default.nix
@@ -8,13 +8,19 @@
 , boost
 , ncurses
 , enableCApi ? true
-# requires numpy
+# Although we handle the Python API's dependencies in pythonEnvArg, this
+# feature is currently disabled as upstream attempts to run `python setup.py
+# install` by itself, and it fails because the Python's environment's prefix is
+# not a writable directly. Adding support for this feature would require using
+# python's pypa/build nad pypa/install hooks directly, and currently it is hard
+# to do that because it all happens after a long buildPhase of the C API.
 , enablePythonApi ? false
 , python3
 , buildPackages
 , enableExamples ? false
-, enableUtils ? false
+, enableUtils ? true
 , libusb1
+# Disable dpdk for now due to compilation issues.
 , enableDpdk ? false
 , dpdk
 # Devices
@@ -43,9 +49,11 @@ in
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "uhd";
-  # UHD seems to use three different version number styles: x.y.z, xxx_yyy_zzz
-  # and xxx.yyy.zzz. Hrmpf... style keeps changing
-  version = "4.4.0.0";
+  # NOTE: Use the following command to update the package, and the uhdImageSrc attribute:
+  #
+  #     nix-shell maintainers/scripts/update.nix --argstr package uhd --argstr commit true
+  #
+  version = "4.6.0.0";
 
   outputs = [ "out" "dev" ];
 
@@ -53,14 +61,24 @@ stdenv.mkDerivation (finalAttrs: {
     owner = "EttusResearch";
     repo = "uhd";
     rev = "v${finalAttrs.version}";
-    sha256 = "sha256-khVOHlvacZc4EMg4m55rxEqPvLY1xURpAfOW905/3jg=";
+    # The updateScript relies on the `src` using `hash`, and not `sha256. To
+    # update the correct hash for the `src` vs the `uhdImagesSrc`
+    hash = "sha256-9ZGt0ZrGbprCmpAuOue6pg2gliu4MvlRFHGxyMJeKAc=";
   };
   # Firmware images are downloaded (pre-built) from the respective release on Github
   uhdImagesSrc = fetchurl {
     url = "https://github.com/EttusResearch/uhd/releases/download/v${finalAttrs.version}/uhd-images_${finalAttrs.version}.tar.xz";
-    sha256 = "V8ldW8bvYWbrDAvpWpHcMeLf9YvF8PIruDAyNK/bru4=";
+    # Please don't convert this to a hash, in base64, see comment near src's
+    # hash.
+    sha256 = "17g503mhndaabrdl7qai3rdbafr8xx8awsyr7h2bdzwzprzmh4m3";
+  };
+  passthru = {
+    updateScript = [
+      ./update.sh
+      # Pass it this file name as argument
+      (builtins.unsafeGetAttrPos "pname" finalAttrs.finalPackage).file
+    ];
   };
-  # TODO: Add passthru.updateScript that will update both of the above hashes...
 
   cmakeFlags = [
     "-DENABLE_LIBUHD=ON"
@@ -123,7 +141,7 @@ stdenv.mkDerivation (finalAttrs: {
   ];
 
   postPhases = [ "installFirmware" "removeInstalledTests" ]
-    ++ optionals (enableUtils && stdenv.targetPlatform.isLinux) [ "moveUdevRules" ]
+    ++ optionals (enableUtils && stdenv.hostPlatform.isLinux) [ "moveUdevRules" ]
   ;
 
   # UHD expects images in `$CMAKE_INSTALL_PREFIX/share/uhd/images`
@@ -144,6 +162,10 @@ stdenv.mkDerivation (finalAttrs: {
     mv $out/lib/uhd/utils/uhd-usrp.rules $out/lib/udev/rules.d/
   '';
 
+  disallowedReferences = optionals (!enablePythonApi && !enableUtils) [
+    python3
+  ];
+
   meta = with lib; {
     description = "USRP Hardware Driver (for Software Defined Radio)";
     longDescription = ''