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