git.iko.soy/typeable/nixpkgs
on master help sign in
uhd: cleanup deps & add many enable / disable flags
commitbcf5a67e2a4aea8a8d58f666b36430b8f74b6de1 authorDoron Behar <doron.behar@gmail.com> dateMon 9 Mar 2020, 17:21 (7 years ago) parentfd2c3ff
1 file changed+81−8
pkgs/applications/radio/uhd/default.nix+81−8
pkgs/applications/radio/uhd/default.nix+81−8
@@ -3,9 +3,32 @@
33, fetchFromGitHub
44, cmake
55, pkgconfig
6−, python
7−, libusb1
6+# See https://files.ettus.com/manual_archive/v3.15.0.0/html/page_build_guide.html for dependencies explanations
87, boost
8+, enableLibuhd_C_api ? true
9+# requires numpy
10+, enableLibuhd_Python_api ? false
11+, python ? null
12+, enableExamples ? false
13+, enableUtils ? false
14+, enableLiberio ? false
15+, liberio ? null
16+, libusb1 ? null
17+, enableDpdk ? false
18+, dpdk ? null
19+# Devices
20+, enableOctoClock ? true
21+, enableMpmd ? true
22+, enableB100 ? true
23+, enableB200 ? true
24+, enableUsrp1 ? true
25+, enableUsrp2 ? true
26+, enableX300 ? true
27+, enableN230 ? true
28+, enableN300 ? true
29+, enableN320 ? true
30+, enableE300 ? true
31+, enableE320 ? true
932}:
1033
1134# You need these udev rules to not have to run as root (copied from
@@ -14,6 +37,11 @@
1437# SUBSYSTEMS=="usb", ATTRS{idVendor}=="fffe", ATTRS{idProduct}=="0002", MODE:="0666"
1538# SUBSYSTEMS=="usb", ATTRS{idVendor}=="2500", ATTRS{idProduct}=="0002", MODE:="0666"
1639
40+let
41+ onOffBool = b: if b then "ON" else "OFF";
42+ inherit (stdenv.lib) optionals;
43+in
44+
1745stdenv.mkDerivation rec {
1846 pname = "uhd";
1947 # UHD seems to use three different version number styles: x.y.z, xxx_yyy_zzz
@@ -35,6 +63,28 @@ stdenv.mkDerivation rec {
3563 enableParallelBuilding = true;
3664
3765 cmakeFlags = [
66+ "-DENABLE_LIBUHD=ON"
67+ "-DENABLE_USB=ON"
68+ "-DENABLE_TESTS=ON" # This installs tests as well so we delete them via postPhases
69+ "-DENABLE_EXAMPLES=${onOffBool enableExamples}"
70+ "-DENABLE_UTILS=${onOffBool enableUtils}"
71+ "-DENABLE_LIBUHD_C_API=${onOffBool enableLibuhd_C_api}"
72+ "-DENABLE_LIBUHD_PYTHON_API=${onOffBool enableLibuhd_Python_api}"
73+ "-DENABLE_LIBERIO=${onOffBool enableLiberio}"
74+ "-DENABLE_DPDK=${onOffBool enableDpdk}"
75+ # Devices
76+ "-DENABLE_OCTOCLOCK=${onOffBool enableOctoClock}"
77+ "-DENABLE_MPMD=${onOffBool enableMpmd}"
78+ "-DENABLE_B100=${onOffBool enableB100}"
79+ "-DENABLE_B200=${onOffBool enableB200}"
80+ "-DENABLE_USRP1=${onOffBool enableUsrp1}"
81+ "-DENABLE_USRP2=${onOffBool enableUsrp2}"
82+ "-DENABLE_X300=${onOffBool enableX300}"
83+ "-DENABLE_N230=${onOffBool enableN230}"
84+ "-DENABLE_N300=${onOffBool enableN300}"
85+ "-DENABLE_N320=${onOffBool enableN320}"
86+ "-DENABLE_E300=${onOffBool enableE300}"
87+ "-DENABLE_E320=${onOffBool enableE320}"
3888 ]
3989 # TODO: Check if this still needed
4090 # ABI differences GCC 7.1
@@ -42,16 +92,34 @@ stdenv.mkDerivation rec {
4292 ++ [ (stdenv.lib.optionalString stdenv.isAarch32 "-DCMAKE_CXX_FLAGS=-Wno-psabi") ]
4393 ;
4494
95+ # Python + Mako are always required for the build itself but not necessary for runtime.
96+ pythonEnv = python.withPackages (ps: with ps; [ Mako ]
97+ ++ optionals (enableLibuhd_Python_api) [ numpy setuptools ]
98+ ++ optionals (enableUtils) [ requests six ]
99+ );
100+
45101 nativeBuildInputs = [
46102 cmake
47103 pkgconfig
48− # Python + Mako are always required for the build itself but not necessary for runtime
49− (python.withPackages (ps: with ps; [ Mako ]))
50− ];
104+ ]
105+ # If both enableLibuhd_Python_api and enableUtils are off, we don't need
106+ # pythonEnv in buildInputs as it's a 'build' dependency and not a runtime
107+ # dependency
108+ ++ optionals (!enableLibuhd_Python_api && !enableUtils) [ pythonEnv ]
109+ ;
51110 buildInputs = [
52− libusb1
53111 boost
54− ];
112+ libusb1
113+ ]
114+ # However, if enableLibuhd_Python_api *or* enableUtils is on, we need
115+ # pythonEnv for runtime as well. The utilities' runtime dependencies are
116+ # handled at the environment
117+ ++ optionals (enableLibuhd_Python_api || enableUtils) [ pythonEnv ]
118+ ++ optionals (enableLiberio) [ liberio ]
119+ ++ optionals (enableDpdk) [ dpdk ]
120+ ;
121+
122+ doCheck = true;
55123
56124 # Build only the host software
57125 preConfigure = "cd host";
@@ -59,7 +127,7 @@ stdenv.mkDerivation rec {
59127 # https://files.ettus.com/manual_archive/v3.15.0.0/html/page_build_guide.html#build_instructions_unix_arm
60128 patches = if stdenv.isAarch32 then ./neon.patch else null;
61129
62− postPhases = [ "installFirmware" ];
130+ postPhases = [ "installFirmware" "removeInstalledTests" ];
63131
64132 # UHD expects images in `$CMAKE_INSTALL_PREFIX/share/uhd/images`
65133 installFirmware = ''
@@ -67,6 +135,11 @@ stdenv.mkDerivation rec {
67135 tar --strip-components=1 -xvf "${uhdImagesSrc}" -C "$out/share/uhd/images"
68136 '';
69137
138+ # -DENABLE_TESTS=ON installs the tests, we don't need them in the output
139+ removeInstalledTests = ''
140+ rm -r $out/lib/uhd/tests
141+ '';
142+
70143 meta = with stdenv.lib; {
71144 description = "USRP Hardware Driver (for Software Defined Radio)";
72145 longDescription = ''