1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 cmake,
6 pkg-config,
7 libX11,
8 glfw,
9 glew,
10 fftwFloat,
11 volk,
12 zstd,
13 # Sources
14 airspy_source ? true,
15 airspy,
16 airspyhf_source ? true,
17 airspyhf,
18 bladerf_source ? true,
19 libbladeRF,
20 file_source ? true,
21 hackrf_source ? true,
22 hackrf,
23 limesdr_source ? true,
24 limesuite,
25 perseus_source ? false, # needs libperseus-sdr, not yet available in nixpks
26 plutosdr_source ? stdenv.hostPlatform.isLinux,
27 libiio,
28 libad9361,
29 rfspace_source ? true,
30 rtl_sdr_source ? true,
31 rtl-sdr-osmocom,
32 libusb1, # osmocom better w/ rtlsdr v4
33 rtl_tcp_source ? true,
34 sdrplay_source ? false,
35 sdrplay,
36 soapy_source ? true,
37 soapysdr-with-plugins,
38 spyserver_source ? true,
39 usrp_source ? false,
40 uhd,
41 boost,
42
43 # Sinks
44 audio_sink ? true,
45 rtaudio,
46 network_sink ? true,
47 portaudio_sink ? false,
48 portaudio,
49
50 # Decoders
51 falcon9_decoder ? false,
52 m17_decoder ? false,
53 codec2,
54 meteor_demodulator ? true,
55 radio ? true,
56 weather_sat_decoder ? false, # is missing some dsp/pll.h
57
58 # Misc
59 discord_presence ? true,
60 frequency_manager ? true,
61 recorder ? true,
62 rigctl_server ? true,
63 scanner ? true,
64}:
65
66stdenv.mkDerivation rec {
67 pname = "sdrpp";
68
69 # SDR++ uses a rolling release model.
70 # Choose a git hash from head and use the date from that commit as
71 # version qualifier
72 git_hash = "27ab5bf3c194169ddf60ca312723fce96149cc8e";
73 git_date = "2024-01-22";
74 version = "1.1.0-unstable-" + git_date;
75
76 src = fetchFromGitHub {
77 owner = "AlexandreRouma";
78 repo = "SDRPlusPlus";
79 rev = git_hash;
80 hash = "sha256-R4xWeqdHEAaje37VQaGlg+L2iYIOH4tXMHvZkZq4SDU=";
81 };
82
83 patches = [ ./runtime-prefix.patch ];
84
85 postPatch = ''
86 substituteInPlace CMakeLists.txt \
87 --replace "/usr/share" "share" \
88 --replace "set(CMAKE_INSTALL_PREFIX" "#set(CMAKE_INSTALL_PREFIX"
89 substituteInPlace decoder_modules/m17_decoder/src/m17dsp.h \
90 --replace "codec2.h" "codec2/codec2.h"
91 # Since the __TIME_ and __DATE__ is canonicalized in the build,
92 # use our qualified version shown in the programs window title.
93 substituteInPlace core/src/version.h --replace "1.1.0" "$version"
94 '';
95
96 nativeBuildInputs = [
97 cmake
98 pkg-config
99 ];
100
101 buildInputs = [
102 glfw
103 glew
104 fftwFloat
105 volk
106 zstd
107 ]
108 ++ lib.optional stdenv.hostPlatform.isLinux libX11
109 ++ lib.optional airspy_source airspy
110 ++ lib.optional airspyhf_source airspyhf
111 ++ lib.optional bladerf_source libbladeRF
112 ++ lib.optional hackrf_source hackrf
113 ++ lib.optional limesdr_source limesuite
114 ++ lib.optionals rtl_sdr_source [
115 rtl-sdr-osmocom
116 libusb1
117 ]
118 ++ lib.optional sdrplay_source sdrplay
119 ++ lib.optional soapy_source soapysdr-with-plugins
120 ++ lib.optionals plutosdr_source [
121 libiio
122 libad9361
123 ]
124 ++ lib.optionals usrp_source [
125 uhd
126 boost
127 ]
128 ++ lib.optional audio_sink rtaudio
129 ++ lib.optional portaudio_sink portaudio
130 ++ lib.optional m17_decoder codec2;
131
132 cmakeFlags = [
133 # Sources
134 (lib.cmakeBool "OPT_BUILD_AIRSPYHF_SOURCE" airspyhf_source)
135 (lib.cmakeBool "OPT_BUILD_AIRSPY_SOURCE" airspy_source)
136 (lib.cmakeBool "OPT_BUILD_BLADERF_SOURCE" bladerf_source)
137 (lib.cmakeBool "OPT_BUILD_FILE_SOURCE" file_source)
138 (lib.cmakeBool "OPT_BUILD_HACKRF_SOURCE" hackrf_source)
139 (lib.cmakeBool "OPT_BUILD_LIMESDR_SOURCE" limesdr_source)
140 (lib.cmakeBool "OPT_BUILD_PERSEUS_SOURCE" perseus_source)
141 (lib.cmakeBool "OPT_BUILD_PLUTOSDR_SOURCE" plutosdr_source)
142 (lib.cmakeBool "OPT_BUILD_RFSPACE_SOURCE" rfspace_source)
143 (lib.cmakeBool "OPT_BUILD_RTL_SDR_SOURCE" rtl_sdr_source)
144 (lib.cmakeBool "OPT_BUILD_RTL_TCP_SOURCE" rtl_tcp_source)
145 (lib.cmakeBool "OPT_BUILD_SDRPLAY_SOURCE" sdrplay_source)
146 (lib.cmakeBool "OPT_BUILD_SOAPY_SOURCE" soapy_source)
147 (lib.cmakeBool "OPT_BUILD_SPYSERVER_SOURCE" spyserver_source)
148 (lib.cmakeBool "OPT_BUILD_USRP_SOURCE" usrp_source)
149
150 # Sinks
151 (lib.cmakeBool "OPT_BUILD_AUDIO_SINK" audio_sink)
152 (lib.cmakeBool "OPT_BUILD_NETWORK_SINK" network_sink)
153 (lib.cmakeBool "OPT_BUILD_NEW_PORTAUDIO_SINK" portaudio_sink)
154
155 # Decoders
156 (lib.cmakeBool "OPT_BUILD_FALCON9_DECODER" falcon9_decoder)
157 (lib.cmakeBool "OPT_BUILD_M17_DECODER" m17_decoder)
158 (lib.cmakeBool "OPT_BUILD_METEOR_DEMODULATOR" meteor_demodulator)
159 (lib.cmakeBool "OPT_BUILD_RADIO" radio)
160 (lib.cmakeBool "OPT_BUILD_WEATHER_SAT_DECODER" weather_sat_decoder)
161
162 # Misc
163 (lib.cmakeBool "OPT_BUILD_DISCORD_PRESENCE" discord_presence)
164 (lib.cmakeBool "OPT_BUILD_FREQUENCY_MANAGER" frequency_manager)
165 (lib.cmakeBool "OPT_BUILD_RECORDER" recorder)
166 (lib.cmakeBool "OPT_BUILD_RIGCTL_SERVER" rigctl_server)
167 (lib.cmakeBool "OPT_BUILD_SCANNER" scanner)
168 ];
169
170 env.NIX_CFLAGS_COMPILE = "-fpermissive";
171
172 hardeningDisable = lib.optional stdenv.cc.isClang "format";
173
174 meta = with lib; {
175 description = "Cross-Platform SDR Software";
176 homepage = "https://github.com/AlexandreRouma/SDRPlusPlus";
177 license = licenses.gpl3Only;
178 platforms = platforms.unix;
179 maintainers = with maintainers; [ sikmir ];
180 mainProgram = "sdrpp";
181 };
182}