1{
2 lib,
3 stdenv,
4 fetchFromGitea,
5 fetchFromGitHub,
6 cmake,
7 pkg-config,
8 libusb1,
9}:
10let
11 generic =
12 {
13 version,
14 pname,
15 src,
16 meta,
17 }:
18 stdenv.mkDerivation {
19 inherit version pname src;
20 nativeBuildInputs = [
21 pkg-config
22 cmake
23 ];
24 propagatedBuildInputs = [ libusb1 ];
25
26 cmakeFlags = lib.optionals stdenv.hostPlatform.isLinux [
27 "-DINSTALL_UDEV_RULES=ON"
28 "-DWITH_RPC=ON"
29 ];
30
31 doInstallCheck = true;
32
33 postPatch = ''
34 substituteInPlace CMakeLists.txt \
35 --replace '/etc/udev/rules.d' "$out/etc/udev/rules.d" \
36 --replace "VERSION_INFO_PATCH_VERSION git" "VERSION_INFO_PATCH_VERSION ${lib.versions.patch version}"
37
38 substituteInPlace rtl-sdr.rules \
39 --replace 'MODE:="0666"' 'ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev"'
40 '';
41
42 meta = with lib; {
43 inherit (meta) longDescription homepage;
44 description = "Software to turn the RTL2832U into a SDR receiver";
45 license = licenses.gpl2Plus;
46 maintainers = with maintainers; [
47 bjornfor
48 skovati
49 Tungsten842
50 ];
51 platforms = platforms.unix;
52 mainProgram = "rtl_sdr";
53 };
54 };
55in
56{
57 rtl-sdr-osmocom = generic rec {
58 pname = "rtl-sdr-osmocom";
59 version = "2.0.1";
60
61 src = fetchFromGitea {
62 domain = "gitea.osmocom.org";
63 owner = "sdr";
64 repo = "rtl-sdr";
65 rev = "v${version}";
66 hash = "sha256-+RYSCn+wAkb9e7NRI5kLY8a6OXtJu7QcSUht1R6wDX0=";
67 };
68 meta = {
69 longDescription = "Rtl-sdr library by the Osmocom project";
70 homepage = "https://gitea.osmocom.org/sdr/rtl-sdr";
71 };
72 };
73
74 rtl-sdr-librtlsdr = generic rec {
75 pname = "rtl-sdr-librtlsdr";
76 version = "0.9.0";
77
78 src = fetchFromGitHub {
79 owner = "librtlsdr";
80 repo = "librtlsdr";
81 rev = "v${version}";
82 hash = "sha256-I1rbywQ0ZBw26wZdtMBkfpj7+kv09XKrrcoDuhIkRmw=";
83 };
84 meta = {
85 longDescription = ''
86 Fork of the rtl-sdr library by the Osmocom project. A list of differences
87 can be found here: https://github.com/librtlsdr/librtlsdr/blob/master/README_improvements.md
88 '';
89 homepage = "https://github.com/librtlsdr/librtlsdr";
90 };
91 };
92
93 rtl-sdr-blog = generic rec {
94 pname = "rtl-sdr-blog";
95 version = "1.3.5";
96
97 src = fetchFromGitHub {
98 owner = "rtlsdrblog";
99 repo = "rtl-sdr-blog";
100 rev = version;
101 hash = "sha256-7FpT+BoQ2U8KiKwX4NfEwrO3lMBti7RX8uKtT5dFH8M=";
102 };
103 meta = {
104 longDescription = ''
105 Fork of the rtl-sdr library by the Osmocom project. A list of differences
106 can be found here: https://github.com/rtlsdrblog/rtl-sdr-blog/blob/master/README
107 '';
108 homepage = "https://github.com/rtlsdrblog/rtl-sdr-blog";
109 };
110 };
111
112}