1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 # Remove gcc and python references
7 removeReferencesTo,
8 pkg-config,
9 volk,
10 cppunit,
11 orc,
12 boost,
13 spdlog,
14 mpir,
15 doxygen,
16 python,
17 codec2,
18 gsm,
19 fftwFloat,
20 alsa-lib,
21 libjack2,
22 libiio,
23 libad9361,
24 uhd,
25 SDL,
26 gsl,
27 soapysdr,
28 libsodium,
29 libsndfile,
30 libunwind,
31 thrift,
32 cppzmq,
33 # Needed only if qt-gui is disabled, from some reason
34 icu,
35 # GUI related
36 gtk3,
37 pango,
38 gobject-introspection,
39 cairo,
40 qt5,
41 libsForQt5,
42 # Features available to override, the list of them is in featuresInfo. They
43 # are all turned on by default.
44 features ? { },
45 # If one wishes to use a different src or name for a very custom build
46 overrideSrc ? { },
47 pname ? "gnuradio",
48 version ? "3.10.12.0",
49}:
50
51let
52 sourceSha256 = "sha256-489Pc6z6Ha7jkTzZSEArDQJGkWdWRDIn1uhfFyLLiCo=";
53 featuresInfo = {
54 # Needed always
55 basic = {
56 native = [
57 cmake
58 pkg-config
59 orc
60 ];
61 runtime = [
62 volk
63 boost
64 spdlog
65 mpir
66 ]
67 # when gr-qtgui is disabled, icu needs to be included, otherwise
68 # building with boost 1.7x fails
69 ++ lib.optionals (!(hasFeature "gr-qtgui")) [ icu ];
70 pythonNative = with python.pkgs; [
71 mako
72 six
73 ];
74 };
75 doxygen = {
76 native = [ doxygen ];
77 cmakeEnableFlag = "DOXYGEN";
78 };
79 man-pages = {
80 cmakeEnableFlag = "MANPAGES";
81 };
82 python-support = {
83 pythonRuntime = [ python.pkgs.six ];
84 native = [
85 python
86 ];
87 cmakeEnableFlag = "PYTHON";
88 };
89 testing-support = {
90 native = [ cppunit ];
91 cmakeEnableFlag = "TESTING";
92 };
93 post-install = {
94 cmakeEnableFlag = "POSTINSTALL";
95 };
96 gnuradio-runtime = {
97 cmakeEnableFlag = "GNURADIO_RUNTIME";
98 pythonRuntime = [
99 python.pkgs.pybind11
100 ];
101 };
102 gr-ctrlport = {
103 runtime = [
104 libunwind
105 thrift
106 ];
107 pythonRuntime = [
108 python.pkgs.thrift
109 # For gr-perf-monitorx
110 python.pkgs.matplotlib
111 python.pkgs.networkx
112 ];
113 cmakeEnableFlag = "GR_CTRLPORT";
114 };
115 gnuradio-companion = {
116 pythonRuntime = with python.pkgs; [
117 pyyaml
118 mako
119 numpy
120 pygobject3
121 ];
122 native = [
123 python.pkgs.pytest
124 ];
125 runtime = [
126 gtk3
127 pango
128 gobject-introspection
129 cairo
130 libsndfile
131 ];
132 cmakeEnableFlag = "GRC";
133 };
134 jsonyaml_blocks = {
135 pythonRuntime = [
136 python.pkgs.jsonschema
137 ];
138 cmakeEnableFlag = "JSONYAML_BLOCKS";
139 };
140 gr-blocks = {
141 cmakeEnableFlag = "GR_BLOCKS";
142 runtime = [
143 # Required to compile wavfile blocks.
144 libsndfile
145 ];
146 };
147 gr-fec = {
148 cmakeEnableFlag = "GR_FEC";
149 };
150 gr-fft = {
151 runtime = [ fftwFloat ];
152 cmakeEnableFlag = "GR_FFT";
153 };
154 gr-filter = {
155 runtime = [ fftwFloat ];
156 cmakeEnableFlag = "GR_FILTER";
157 pythonRuntime = with python.pkgs; [
158 scipy
159 pyqtgraph
160 pyqt5
161 ];
162 };
163 gr-analog = {
164 cmakeEnableFlag = "GR_ANALOG";
165 };
166 gr-digital = {
167 cmakeEnableFlag = "GR_DIGITAL";
168 };
169 gr-dtv = {
170 cmakeEnableFlag = "GR_DTV";
171 };
172 gr-audio = {
173 runtime =
174 [ ]
175 ++ lib.optionals stdenv.hostPlatform.isLinux [
176 alsa-lib
177 libjack2
178 ];
179 cmakeEnableFlag = "GR_AUDIO";
180 };
181 gr-channels = {
182 cmakeEnableFlag = "GR_CHANNELS";
183 };
184 gr-pdu = {
185 cmakeEnableFlag = "GR_PDU";
186 runtime = [
187 libiio
188 libad9361
189 ];
190 };
191 gr-iio = {
192 cmakeEnableFlag = "GR_IIO";
193 runtime = [
194 libiio
195 ];
196 };
197 common-precompiled-headers = {
198 cmakeEnableFlag = "COMMON_PCH";
199 };
200 gr-qtgui = {
201 runtime = [
202 qt5.qtbase
203 libsForQt5.qwt
204 ];
205 pythonRuntime = [ python.pkgs.pyqt5 ];
206 cmakeEnableFlag = "GR_QTGUI";
207 };
208 gr-trellis = {
209 cmakeEnableFlag = "GR_TRELLIS";
210 };
211 gr-uhd = {
212 runtime = [
213 uhd
214 ];
215 cmakeEnableFlag = "GR_UHD";
216 };
217 gr-uhd-rfnoc = {
218 runtime = [
219 uhd
220 ];
221 cmakeEnableFlag = "UHD_RFNOC";
222 };
223 gr-utils = {
224 cmakeEnableFlag = "GR_UTILS";
225 pythonRuntime = with python.pkgs; [
226 # For gr_plot
227 matplotlib
228 ];
229 };
230 gr-modtool = {
231 pythonRuntime = with python.pkgs; [
232 setuptools
233 click
234 click-plugins
235 pygccxml
236 ];
237 cmakeEnableFlag = "GR_MODTOOL";
238 };
239 gr-blocktool = {
240 cmakeEnableFlag = "GR_BLOCKTOOL";
241 };
242 gr-video-sdl = {
243 runtime = [ SDL ];
244 cmakeEnableFlag = "GR_VIDEO_SDL";
245 };
246 gr-vocoder = {
247 runtime = [
248 codec2
249 gsm
250 ];
251 cmakeEnableFlag = "GR_VOCODER";
252 };
253 gr-wavelet = {
254 cmakeEnableFlag = "GR_WAVELET";
255 runtime = [
256 gsl
257 libsodium
258 ];
259 };
260 gr-zeromq = {
261 runtime = [ cppzmq ];
262 cmakeEnableFlag = "GR_ZEROMQ";
263 pythonRuntime = [
264 # Will compile without this, but it is required by tests, and by some
265 # gr blocks.
266 python.pkgs.pyzmq
267 ];
268 };
269 gr-network = {
270 cmakeEnableFlag = "GR_NETWORK";
271 };
272 gr-soapy = {
273 cmakeEnableFlag = "GR_SOAPY";
274 runtime = [
275 soapysdr
276 ];
277 };
278 };
279 shared = (
280 import ./shared.nix {
281 inherit
282 stdenv
283 lib
284 python
285 removeReferencesTo
286 featuresInfo
287 features
288 version
289 sourceSha256
290 overrideSrc
291 fetchFromGitHub
292 ;
293 qt = qt5;
294 gtk = gtk3;
295 }
296 );
297 inherit (shared.passthru) hasFeature; # function
298in
299
300stdenv.mkDerivation (
301 finalAttrs:
302 (
303 shared
304 // {
305 inherit pname version;
306 # Will still evaluate correctly if not used here. It only helps nix-update
307 # find the right file in which version is defined.
308 inherit (shared) src;
309 patches = [
310 # Not accepted upstream, see https://github.com/gnuradio/gnuradio/pull/5227
311 ./modtool-newmod-permissions.patch
312 ];
313 passthru =
314 shared.passthru
315 // {
316 # Deps that are potentially overridden and are used inside GR plugins - the same version must
317 inherit
318 boost
319 volk
320 ;
321 # Used by many gnuradio modules, the same attribute is present in
322 # previous gnuradio versions where there it's log4cpp.
323 logLib = spdlog;
324 }
325 // lib.optionalAttrs (hasFeature "gr-uhd") {
326 inherit uhd;
327 }
328 // lib.optionalAttrs (hasFeature "gr-pdu") {
329 inherit libiio libad9361;
330 }
331 // lib.optionalAttrs (hasFeature "gr-qtgui") {
332 inherit (libsForQt5) qwt;
333 };
334
335 postInstall =
336 shared.postInstall
337 # This is the only python reference worth removing, if needed.
338 + lib.optionalString (!hasFeature "python-support") ''
339 remove-references-to -t ${python} $out/lib/cmake/gnuradio/GnuradioConfig.cmake
340 remove-references-to -t ${python} $(readlink -f $out/lib/libgnuradio-runtime${stdenv.hostPlatform.extensions.sharedLibrary})
341 remove-references-to -t ${python.pkgs.pybind11} $out/lib/cmake/gnuradio/gnuradio-runtimeTargets.cmake
342 '';
343 }
344 )
345)