10 # See https://files.ettus.com/manual_archive/v3.15.0.0/html/page_build_guide.html for dependencies explanations
14 enablePythonApi ? true,
16 enableExamples ? false,
19 # Disable dpdk for now due to compilation issues.
23 enableOctoClock ? true,
37 inherit (lib) optionals cmakeBool;
40 stdenv.mkDerivation (finalAttrs: {
42 # NOTE: Use the following command to update the package, and the uhdImageSrc attribute:
44 # nix-shell maintainers/scripts/update.nix --argstr package uhd --argstr commit true
53 src = fetchFromGitHub {
54 owner = "EttusResearch";
56 rev = "v${finalAttrs.version}";
57 # The updateScript relies on the `src` using `hash`, and not `sha256. To
58 # update the correct hash for the `src` vs the `uhdImagesSrc`
59 hash = "sha256-TX1iLs941z8sZY0yQEXuy9jGgsn6HU4uqIdxJmNNahU=";
61 # Firmware images are downloaded (pre-built) from the respective release on Github
62 uhdImagesSrc = fetchurl {
63 url = "https://github.com/EttusResearch/uhd/releases/download/v${finalAttrs.version}/uhd-images_${finalAttrs.version}.tar.xz";
64 # Please don't convert this to a hash, in base64, see comment near src's
66 sha256 = "17g503mhndaabrdl7qai3rdbafr8xx8awsyr7h2bdzwzprzmh4m3";
68 # This are the minimum required Python dependencies, this attribute might
69 # be useful if you want to build a development environment with a python
70 # interpreter able to import the uhd module.
72 optionals (enablePythonApi || enableUtils) [
74 python3.pkgs.setuptools
76 ++ optionals (enableUtils) [
81 These deps are needed for the usrp_hwd.py utility, however even if they
82 would have been added here, the utility wouldn't have worked because it
83 depends on an old python library mprpc that is not supported for Python >
84 3.8. See also report upstream:
85 https://github.com/EttusResearch/uhd/issues/744
93 runtimePython = python3.withPackages (ps: finalAttrs.pythonPath);
96 # Pass it this file name as argument
97 (builtins.unsafeGetAttrPos "pname" finalAttrs.finalPackage).file
105 # Regardless of doCheck, we want to build the tests to help us gain
106 # confident that the package is OK.
108 (cmakeBool "ENABLE_EXAMPLES" enableExamples)
109 (cmakeBool "ENABLE_UTILS" enableUtils)
110 (cmakeBool "ENABLE_C_API" enableCApi)
111 (cmakeBool "ENABLE_PYTHON_API" enablePythonApi)
113 Otherwise python tests fail. Using a dedicated pythonEnv for either or both
114 nativeBuildInputs and buildInputs makes upstream's cmake scripts fail to
115 install the Python API as reported on our end at [1] (we don't want
116 upstream to think we are in a virtual environment because we use
117 python3.withPackages...).
119 Putting simply the python dependencies in the nativeBuildInputs and
120 buildInputs as they are now from some reason makes the `python` in the
121 checkPhase fail to find the python dependencies, as reported at [2]. Even
122 using nativeCheckInputs with the python dependencies, or using a
123 `python3.withPackages` wrapper in nativeCheckInputs, doesn't help, as the
124 `python` found in $PATH first is the one from nativeBuildInputs.
126 [1]: https://github.com/NixOS/nixpkgs/pull/307435
127 [2]: https://discourse.nixos.org/t/missing-python-package-in-checkphase/9168/
129 Hence we use upstream's provided cmake flag to control which python
130 interpreter they will use to run the the python tests.
132 "-DRUNTIME_PYTHON_EXECUTABLE=${lib.getExe finalAttrs.passthru.runtimePython}"
133 (cmakeBool "ENABLE_DPDK" enableDpdk)
135 (cmakeBool "ENABLE_OCTOCLOCK" enableOctoClock)
136 (cmakeBool "ENABLE_MPMD" enableMpmd)
137 (cmakeBool "ENABLE_B100" enableB100)
138 (cmakeBool "ENABLE_B200" enableB200)
139 (cmakeBool "ENABLE_USRP1" enableUsrp1)
140 (cmakeBool "ENABLE_USRP2" enableUsrp2)
141 (cmakeBool "ENABLE_X300" enableX300)
142 (cmakeBool "ENABLE_N300" enableN300)
143 (cmakeBool "ENABLE_N320" enableN320)
144 (cmakeBool "ENABLE_E300" enableE300)
145 (cmakeBool "ENABLE_E320" enableE320)
146 # TODO: Check if this still needed
147 # ABI differences GCC 7.1
148 # /nix/store/wd6r25miqbk9ia53pp669gn4wrg9n9cj-gcc-7.3.0/include/c++/7.3.0/bits/vector.tcc:394:7: note: parameter passing for argument of type 'std::vector<uhd::range_t>::iterator {aka __gnu_cxx::__normal_iterator<uhd::range_t*, std::vector<uhd::range_t> >}' changed in GCC 7.1
150 ++ optionals stdenv.hostPlatform.isAarch32 [
151 "-DCMAKE_CXX_FLAGS=-Wno-psabi"
154 nativeBuildInputs = [
157 # Present both here and in buildInputs for cross compilation.
160 # We add this unconditionally, but actually run wrapPythonPrograms only if
161 # python utilities are enabled
162 python3.pkgs.wrapPython
165 finalAttrs.pythonPath
170 ++ optionals (enableExamples) [
174 ++ optionals (enableDpdk) [
178 # many tests fails on darwin, according to ofborg
179 doCheck = !stdenv.hostPlatform.isDarwin;
181 # Build only the host software
182 preConfigure = "cd host";
184 # fix for boost 187 remove on next update
187 name = "boost-187.patch";
188 url = "https://github.com/EttusResearch/uhd/commit/adfe953d965e58b5931c1b1968899492c8087cf6.patch";
189 hash = "sha256-qzxe6QhGoyBul7YjCiPJfeP+3dIoo1hh2sjgYmc9IiI=";
191 # The last two hunks in client.cc will fail without these substitutions
194 "[buffer, idx, func_name, p, this]"
201 # Disable tests that fail in the sandbox, last checked at version 4.6.0.0
202 ./no-adapter-tests.patch
208 "removeInstalledTests"
210 ++ optionals (enableUtils && stdenv.hostPlatform.isLinux) [
214 # UHD expects images in `$CMAKE_INSTALL_PREFIX/share/uhd/images`
216 mkdir -p "$out/share/uhd/images"
217 tar --strip-components=1 -xvf "${finalAttrs.uhdImagesSrc}" -C "$out/share/uhd/images"
220 # -DENABLE_TESTS=ON installs the tests, we don't need them in the output
221 removeInstalledTests = ''
222 rm -r $out/lib/uhd/tests
225 # Moves the udev rules to the standard location, needed only if utils are
228 mkdir -p $out/lib/udev/rules.d
229 mv $out/lib/uhd/utils/uhd-usrp.rules $out/lib/udev/rules.d/
232 # Wrap the python utilities with our pythonPath definition
233 postFixup = lib.optionalString (enablePythonApi && enableUtils) ''
236 disallowedReferences = optionals (!enablePythonApi && !enableUtils) [
241 description = "USRP Hardware Driver (for Software Defined Radio)";
243 The USRP Hardware Driver (UHD) software is the hardware driver for all
244 USRP (Universal Software Radio Peripheral) devices.
246 USRP devices are designed and sold by Ettus Research, LLC and its parent
247 company, National Instruments.
249 homepage = "https://uhd.ettus.com/";
250 license = licenses.gpl3Plus;
251 platforms = platforms.linux ++ platforms.darwin;
252 maintainers = with maintainers; [