Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / applications / radio / gnuradio / default.nix
blob6a04491a5cee76a75fcd5693c6493f0a037351a8
1 { lib, stdenv
2 , fetchFromGitHub
3 , cmake
4 # Remove gcc and python references
5 , removeReferencesTo
6 , pkg-config
7 , volk
8 , cppunit
9 , orc
10 , boost
11 , spdlog
12 , mpir
13 , doxygen
14 , python
15 , codec2
16 , gsm
17 , fftwFloat
18 , alsa-lib
19 , libjack2
20 , libiio
21 , libad9361
22 , CoreAudio
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.isLinux [ alsa-lib libjack2 ]
174         ++ lib.optionals stdenv.isDarwin [ CoreAudio ]
175       ;
176       cmakeEnableFlag = "GR_AUDIO";
177     };
178     gr-channels = {
179       cmakeEnableFlag = "GR_CHANNELS";
180     };
181     gr-pdu = {
182       cmakeEnableFlag = "GR_PDU";
183       runtime = [
184         libiio
185         libad9361
186       ];
187     };
188     gr-iio = {
189       cmakeEnableFlag = "GR_IIO";
190       runtime = [
191         libiio
192       ];
193     };
194     common-precompiled-headers = {
195       cmakeEnableFlag = "COMMON_PCH";
196     };
197     gr-qtgui = {
198       runtime = [ qt5.qtbase libsForQt5.qwt ];
199       pythonRuntime = [ python.pkgs.pyqt5 ];
200       cmakeEnableFlag = "GR_QTGUI";
201     };
202     gr-trellis = {
203       cmakeEnableFlag = "GR_TRELLIS";
204     };
205     gr-uhd = {
206       runtime = [
207         uhd
208       ];
209       cmakeEnableFlag = "GR_UHD";
210     };
211     gr-uhd-rfnoc = {
212       runtime = [
213         uhd
214       ];
215       cmakeEnableFlag = "UHD_RFNOC";
216     };
217     gr-utils = {
218       cmakeEnableFlag = "GR_UTILS";
219       pythonRuntime = with python.pkgs; [
220         # For gr_plot
221         matplotlib
222       ];
223     };
224     gr-modtool = {
225       pythonRuntime = with python.pkgs; [
226         setuptools
227         click
228         click-plugins
229         pygccxml
230       ];
231       cmakeEnableFlag = "GR_MODTOOL";
232     };
233     gr-blocktool = {
234       cmakeEnableFlag = "GR_BLOCKTOOL";
235     };
236     gr-video-sdl = {
237       runtime = [ SDL ];
238       cmakeEnableFlag = "GR_VIDEO_SDL";
239     };
240     gr-vocoder = {
241       runtime = [ codec2 gsm ];
242       cmakeEnableFlag = "GR_VOCODER";
243     };
244     gr-wavelet = {
245       cmakeEnableFlag = "GR_WAVELET";
246       runtime = [ gsl libsodium ];
247     };
248     gr-zeromq = {
249       runtime = [ cppzmq ];
250       cmakeEnableFlag = "GR_ZEROMQ";
251       pythonRuntime = [
252         # Will compile without this, but it is required by tests, and by some
253         # gr blocks.
254         python.pkgs.pyzmq
255       ];
256     };
257     gr-network = {
258       cmakeEnableFlag = "GR_NETWORK";
259     };
260     gr-soapy = {
261       cmakeEnableFlag = "GR_SOAPY";
262       runtime = [
263         soapysdr
264       ];
265     };
266   };
267   shared = (import ./shared.nix {
268     inherit
269       stdenv
270       lib
271       python
272       removeReferencesTo
273       featuresInfo
274       features
275       version
276       sourceSha256
277       overrideSrc
278       fetchFromGitHub
279     ;
280     qt = qt5;
281     gtk = gtk3;
282   });
283   inherit (shared.passthru) hasFeature; # function
286 stdenv.mkDerivation (finalAttrs: (shared // {
287   inherit pname version;
288   # Will still evaluate correctly if not used here. It only helps nix-update
289   # find the right file in which version is defined.
290   inherit (shared) src;
291   patches = [
292     # Not accepted upstream, see https://github.com/gnuradio/gnuradio/pull/5227
293     ./modtool-newmod-permissions.patch
294   ];
295   passthru = shared.passthru // {
296     # Deps that are potentially overridden and are used inside GR plugins - the same version must
297     inherit
298       boost
299       volk
300     ;
301     # Used by many gnuradio modules, the same attribute is present in
302     # previous gnuradio versions where there it's log4cpp.
303     logLib = spdlog;
304   } // lib.optionalAttrs (hasFeature "gr-uhd") {
305     inherit uhd;
306   } // lib.optionalAttrs (hasFeature "gr-pdu") {
307     inherit libiio libad9361;
308   } // lib.optionalAttrs (hasFeature "gr-qtgui") {
309     inherit (libsForQt5) qwt;
310   };
312   postInstall = shared.postInstall
313     # This is the only python reference worth removing, if needed.
314     + lib.optionalString (!hasFeature "python-support") ''
315       ${removeReferencesTo}/bin/remove-references-to -t ${python} $out/lib/cmake/gnuradio/GnuradioConfig.cmake
316       ${removeReferencesTo}/bin/remove-references-to -t ${python} $(readlink -f $out/lib/libgnuradio-runtime${stdenv.hostPlatform.extensions.sharedLibrary})
317       ${removeReferencesTo}/bin/remove-references-to -t ${python.pkgs.pybind11} $out/lib/cmake/gnuradio/gnuradio-runtimeTargets.cmake
318     ''
319   ;